赞
踩
- //
- // main.c
- // Test
- //
-
-
- char *my_strcat(char *str1, char *str2)
- {
- char *pt = str1;
- while(*str1!='\0') str1++;
- while(*str2!='\0') *str1++ = *str2++;
- *str1 = '\0';
- return pt;
- }
-
- int main(int argc, const char * argv[]) {
-
- char d[127]="abc"; //注意这里要为第一个串预留够用的内存
- char *s="efg";
- printf("len1:%d \r\n",strlen(&d));
- my_strcat(d,s); //拼接两个字符串,结果保存在第一个字符串当中
- printf("rs:%s \r\n",d); //输出拼接结果:"字符串1字符串2"
- printf("len2:%d \r\n",strlen(&d));
-
- return 0;
- }
-
-

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。