strcat函数实现

#include <iostream>
using namespace std;

char* strcatcp(char *des, char *source1, char *source2)
{
char *p = des;
while ((*des++=*source1++)!='\0');
des--;
while ((*des++=*source2++)!='\0');
return p;
}

int main(void)
{
char *des, *source1, *source2;
des = (char *)malloc(sizeof(source1)+sizeof(source2));
source1 = "hello";
source2 = "world";
des = strcatcp(des, source1, source2);
cout<<des<<endl;

return 0;
}

posted @ 2012-10-17 09:58  SA高处不胜寒  阅读(632)  评论(0编辑  收藏  举报