C语言:strcat函数的实现

#define _CRT_SECURE_NO_WARNINGS//strcat
#include
#include
#include
#include

int my_strcat( char *dest, const char *str)
{
 assert(dest != NULL&str != NULL);
 const char* d = dest;
 const char* s = str;

 while (*dest != '\0')
 {
  dest++;
 }
 while (*dest++ = *str++);
 return d;

 

}
int main()
{
 char arr1[20] = "abc";
 char arr2[20] = "abcd";

 printf("%s", my_strcat(arr1, arr2));

 system("pause");
 return 0;
}

你可能感兴趣的:(代码)