//程序有错,正确的如下:
#include
int main()
{
void string_copy (char *from,char *to); //改过!改过!改过!改过!
char a[100]="I am a student"; //改过!改过!改过!改过!
char b[100]="You are a teacher"; //改过!改过!改过!改过!
printf("String a is %s:\nString b is %s:\n",a,b);
string_copy(a,b);
printf("String a is %s;\nString b is %s:\n",a,b);
system("pause");
return 0;
}
void string_copy (char *from,char *to) //改过!改过!改过!改过!
{
while ((*to=*from)!='\0')
{
to++;from++;
}
}
我试了一下
有以下问题:
a.cpp: In function 'int main()':
a.cpp:5:10: warning: deprecated conversion from string constant to 'char*' [-Wwr
ite-strings]
a.cpp:6:10: warning: deprecated conversion from string constant to 'char*' [-Wwr
ite-strings]
a.cpp:8:16: error: cannot convert 'char*' to 'char**' for argument '1' to 'void
string_copy(char**, char**)'
a.cpp:10:15: error: 'system' was not declared in this scope
前两个是警告可以暂时不管
第三个应该是你代码写错了
最后那个system函数 需要#include
你在主函数最后加一句getchar();
对了,是return 前面