问:实现两个字符串的追加
#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> #include <assert.h> #include <string.h> int main() { char arr1[20] = "abcdef"; char arr2[] = "yue"; strcat(arr1, arr2); printf("%s", arr1); return 0; }
#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> #include <assert.h> #include <string.h> char* my_strcat(char* dest, char* str) { char* ret = dest; assert(dest); assert(str); while(*dest != '\0') { dest++; } while(*dest++ = *str++) { ; } return ret; } int main() { char arr1[20] = "abcdef"; char arr2[] = "yue"; my_strcat(arr1, arr2); printf("%s", arr1); return 0; }
标签:39,dest,代码,练习,strcat,char,arr2,arr1,include From: https://www.cnblogs.com/ayue6/p/17792124.html