编写一段C++程序,定义两个字符数组并用字符串字面值初始化他们;
接着再定义一个字符数组存放前两个数组连接后的结果。使用strcpy和strcat把前面两个数组的内容拷贝到第三个数组中。
编写一段C++程序,利用strcpy和strcat
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
5条回答
- 华仔funny 2015-08-16 04:06关注
#include "stdafx.h"
#include "string.h"int _tmain(int argc, _TCHAR* argv[])
{
char buf1[] = "hello";
char buf2[] = "world";
char buf3[] = "";
strcat(buf3,buf1);
strcat(buf3,buf2);
printf("%s",buf3);
getchar();
return 0;
}用strcat 拼接,VS2012编译,输入出拼接后字符串helloworld
解决 无用评论 打赏 举报