qjwlfxx 2015-08-16 03:11 采纳率: 33.3%
浏览 1847

编写一段C++程序,利用strcpy和strcat

编写一段C++程序,定义两个字符数组并用字符串字面值初始化他们;
接着再定义一个字符数组存放前两个数组连接后的结果。使用strcpy和strcat把前面两个数组的内容拷贝到第三个数组中。

  • 写回答

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

    评论

报告相同问题?