- #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 *strdest = dest;
- while (*dest)
- {
- dest++;
- }
- while (*dest++ = *src++)
- {
- ;
- }
- return strdest;
- }
- int main()
- {
- char arr1[20] = "hello ";
- char arr2[] = "world!";
- char* ret = my_strcat(arr1, arr2);
- printf("%s", ret);
- system("pause");
- return 0;
- }
模拟实现strcat
最新推荐文章于 2019-06-05 10:54:03 发布