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

运行结果:

posted @ 2017-09-17 10:04  一串字符串  阅读(3441)  评论(0编辑  收藏  举报