字符指针问题,求助
程序代码:
#include<stdio.h> void main() { void copy_string(char *from,char *to); char from[] = "I am a teacher."; char to[] = "You are a student."; char *a = from,*b = to; printf("%c\n",*from); printf("string a = %s\nstring b =%s\n",a,b); printf("copy string a to string b\n"); copy_string(a,b); printf("string a = %s\nstring b =%s\n",a,b); } void copy_string(char *from,char *to) { for(;*from!='\0';from++,to++) *to = *from; *to = '\0'; }我将代码中的 from[] 和 to[] 改成了字符指针 *from 和 *to,调试就会出现错误
望各位大侠指点迷津,帮我这个小菜鸟指出错误,非常感谢