开发者社区> 问答> 正文

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

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

展开
收起
a123456678 2016-03-06 15:35:53 2195 0
1 条回答
写回答
取消 提交回答
  • #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

    2019-07-17 18:54:44
    赞同 展开评论 打赏
问答分类:
C++
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
使用C++11开发PHP7扩展 立即下载
GPON Class C++ SFP O;T Transce 立即下载
GPON Class C++ SFP OLT Transce 立即下载