c语言实现strcpy函数

来源:互联网 发布:天使之城淘宝店不在了 编辑:程序博客网 时间:2024/05/17 00:10
#include <stdio.h>
#include <windows.h>
int strcpy(char *str1, char *str2);
int main()
{
char str1[100] = {0};
char *s = "helloworld";
strcpy(str1, s);
printf("%s\n", str1);



system("pause");
return 0;
}


int strcpy(char *str1, char *str2)
{
if (str1 == NULL || str2 == NULL)
{
return -1;
}
   while (*str2 != '\0')
   {
  *str1 = *str2;
  str1++;
  str2++;
   }
   return 0;
}
原创粉丝点击