#include<stdio.h> #include<stdlib.h> #include<string.h> #include<assert.h> char*my_strcat(char*dest, const char*src) { assert(dest!=NULL); assert(src); char*ret = dest; while (*dest) { dest++; } while (*dest++ = *src++) { ; } return ret; } int main() { char *p = "bit"; char arr[20] = "hello"; printf("%s\n", my_strcat(arr, p)); system("pause"); return 0; }
结果:
hellobit
时间: 2024-10-12 11:51:34