错误代码:
#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);
}
问下为什么这样改就对了?
C语言编译中返回指针问题
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-