大侠们,帮帮兄弟啊
这是怎么回事#include<stdio.h>
#include<string.h>
#define MAX_SIZE 100
char *Copy(char string1[], char string2[]);
main()
{
char str[]={"mashaofei"};
char substr[]={'\0'};
char *ptr;
ptr=Copy(substr,str);
printf("%s\n",ptr);
printf("%s",str);//为什么这里输出时str变了,前四个字符不见了,输出为 ao fei了,不知哪里出错了?
}
char *Copy(char string1[], char string2[])
{
int count=0;
while(string2[count]!='\0')
{
string1[count]=string2[count];
count++;
}
string1[count]='\0';
return string1;
}