错误代码:
#include
char 指针*strcpy(char , char);
int main(void)
{
char a[20], b[60] = "there is a boat on the lake.";
printf("%s\n", strcpy(a, b));
return 0;
}
char 指针*strcpy(char s, char *t)
{
while(*s++ = *t++)
;
return (s);
}
正确代码:
#include
char *strcpy(char *, char);
int main(void)
{
char a[20],b[60]="there is a boat on the lake.";
printf("%s\n", strcpy(a, b));
return 0;
}
char *strcpy(char *s, char *t)
{
char *m;
m=s;
while(*s++=*t++)
;
return (m);
}
问下为什么这样改就对了?
char是一个字节,char*是地址,就这么简单的区别啊。还有哪里有问题?
使用这个模式发代码。。。保证代码正确性!!!