*** 自写代码:实现库函数strcat()

#include <iostream>
#include <string.h>
using namespace std;
char * strcat1 (char * dest, char * src)
{
if ((dest==NULL) || (src==NULL)) return NULL;
char * start = dest;
while(*dest++ != '\0');
dest--;
while ((*dest++=*src++) != '\0');
return start;
}
int main()
{
char a[10] = "123";
char b[] = "456";
cout << strcat1(a, b) << endl;
}

posted @ 2018-12-23 19:00  super行者  阅读(341)  评论(0编辑  收藏  举报