#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> #include<stdlib.h> #include<assert.h> #include<string.h> char *my_strncat(char *dest, char *src, int len) { assert(dest); assert(src); char *ret = dest; while (*dest) { dest++; } while (len--) { *dest = *src; dest++; src++; } *dest = '\0'; return ret; } int main() { char arr[20] = "hello "; int len = strlen(arr); char *ret = my_strncat(arr, arr, len); printf("%s", ret); system("pause"); return 0; }