#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 80
char* strcopy(char*,char*);
int main()
{
char str1[SIZE];
char str2[SIZE];
printf("请输入一个字符串:");
scanf("%s",str2);
strcpy(str1,str2);
printf("已复制字符串:%s\n",str1);
scanf("%s",str2);
// system("pause"); //等待一个按键然后返回
return 0;
}
char* strcopy(char* str1,char* str2)
{
static int i=0;
while(*(str2+i) != "\0")
{
*(str1+i) = *(str2+i);
i++;
}
*(str1+i) = "\0";
return str1;
}
字符串复制函数的实现
最新推荐文章于 2023-02-19 15:53:02 发布