#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> #include<stdlib.h> #include<assert.h> char *my_strcat(char *dest, char *src) { assert(dest); assert(src); char *ret = src; while (*src) { src++; } while (*src++ = *dest++) { ; } return ret; } int main() { char arr1[20] = "hello "; char arr2[] = "world!"; char *ret = my_strcat(arr2, arr1); printf("%s", ret); system("pause"); return 0; }
时间: 2024-11-29 05:15:34