字符串拼接strcat
char *mystrcat(char *dest,const char *source) { char *pstart = dest; while (*pstart != '\0') { pstart++; } //从尾部 while ((*pstart++)=(*source++)) { } } void main() { char str1[22] = "zhouruifu"; char str2[11] = "-rocket"; printf("str1=%s str2=%s\n", str1, str2); mystrcat(str1, str2);//拼接字符串 printf("str1=%s\n", str1); system("pause"); }
版权声明:本文为博主原创文章,欢迎指出代码不良之处,及提出代码优化方案。欢迎指点,黑夜代码,拼命奋斗,努力更新中......
时间: 2024-10-13 00:28:15