zhiye_wang

向星空仰望的越深,越发现自己的渺小

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  31 随笔 :: 1 文章 :: 2 评论 :: 0 Trackbacks
 1 #include "stdafx.h"
 2 #include "iostream"
 3 #include "assert.h"
 4 #include "string"
 5 
 6 using namespace std;
 7 
 8 char* mystrcat(char* dest, const char* src)
 9 {
10     assert(dest!=NULL && src!=NULL);
11     char* p = dest;
12     while (*p!='\0') 
13         p++;
14     while (*p++ = *src++);
15     *p = '\0';
16     return dest;
17 }
18 
19 int main(int argc, char* argv[])
20 {
21     printf("Hello World!\n");
22     char buf[10] = "FU ";
23     char test[4] = "CK!";
24     mystrcat(buf, test);
25     cout << buf << endl;
26     return 0;
27 }
输出:
Hello World!
FU CK!
Press any key to continue
posted on 2014-06-12 09:59 zhiye_wang 阅读(172) 评论(0)  编辑 收藏 引用 所属分类: C/C++通用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理