用字符指针作函数参数
为什么得不到复制后的结果,到底错在哪了?#include<stdio.h>
void main()
{
void copy_string(char * from,char * to);
char * a="I am a teacher."; // char from[]="I am a teacher.",* a=from;
char * b="you are a student."; // char to[]="you are a student.",* b=to;
printf("string a=%s\nstring b=%s\n",a,b);
printf("copy string a to string b:\n");
copy_string(a,b);
printf("\nstring a=%s\nstring b=%s\n",a,b);
}
void copy_string(char * from,char * to)
{
for(;* from!='\0';from++,to++)
* to=* from;
* to='\0';
}