C++入門經典-例6.15-通過字符串函數連接兩個字符數組


1:代碼如下

// 6.15.cpp : 定義控制台應用程序的入口點。
//


#include "stdafx.h"
#include <iostream>
using namespace std;
void main()
{
    char str1[50], str2[30], *p1, *p2;
    p1 = str1;
    p2 = str2;
    cout << "please input string1:" << endl;
    gets_s(str1);
    cout << "please input string2:" << endl;
    gets_s(str2);
    strcat_s(str1, str2);//對字符串也行,對數組也行
    cout << "the new string is:" << endl;
    puts(str1);
}
View Code

運行結果:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM