int main()
{
void copy_string(char *from, char *to);
char *a = "I am a teacher.";
char *b = "You are a student.";
printf("string a = %s\nstring b = %s\n", a, b);
printf("copy string a to string b:\n");
copy_string(a, b);
printf("stirng a = %s\nstring b = %s\n", a, b);
system("pause");
return 0;
}
void copy_string(char *from, char *to)
{
for (; *from != *\0*; from++,to++)
*to = (*from);
*to = *\0*;
}
不能正常运行
程序1在main里,为何定义
char *a = "I am a teacher.";
char b[] = "You are a student.";
char *p = b;
这段能用
copy_string(a,p)调用,正常运行
程序2里这样定义:
char *a = "I am a teacher.";
char *b = "You are a student.";
函数调用copy_string(a,b)就不行呢????
{
void copy_string(char *from, char *to);
char *a = "I am a teacher.";
char *b = "You are a student.";
printf("string a = %s\nstring b = %s\n", a, b);
printf("copy string a to string b:\n");
copy_string(a, b);
printf("stirng a = %s\nstring b = %s\n", a, b);
system("pause");
return 0;
}
void copy_string(char *from, char *to)
{
for (; *from != *\0*; from++,to++)
*to = (*from);
*to = *\0*;
}
不能正常运行
程序1在main里,为何定义
char *a = "I am a teacher.";
char b[] = "You are a student.";
char *p = b;
这段能用
copy_string(a,p)调用,正常运行
程序2里这样定义:
char *a = "I am a teacher.";
char *b = "You are a student.";
函数调用copy_string(a,b)就不行呢????