int arrayCopy(char *from,char * to)
{ //不要轻易改变形参的值,引用辅助指针变量,把形参接过来;
char *myfrom=from;
char *myto=to;
if(from==NULL||to==NULL)//if语句增强程序健壮性
{
return -1;
}
while(*myto=*myfrom)
{
myfrom++;
myto++;
}
}
int main()
{
char from[]="COPY ARRAY";
char myArray[100];
arrayCopy(from,myArray);
printf("%s\n",myArray);
system("pause");
return;
}
int arrayCopy(char *from,char * to)
{ //不要轻易改变形参的值,引用辅助指针变量,把形参接过来;
char *myfrom=from;
char *myto=to;
if(from==NULL||to==NULL)//if语句增强程序健壮性
{
return -1;
}
while(*myto=*myfrom)
{
myfrom++;
myto++;
}
}
int main()
{
char from[]="COPY ARRAY";
char myArray[100];
arrayCopy(from,myArray);
printf("%s\n",myArray);
system("pause");
return;
}