1
0

c8-20-2.c 450 B

12345678910111213141516171819
  1. #include <stdio.h>
  2. int main()
  3. {void copy_string(char from[], char to[]);
  4. char a[]="I am a teacher.";
  5. char b[]="you are a student.";
  6. char *from=a,*to=b;
  7. printf("string a=%s\nstring b=%s\n",a,b);
  8. printf("\ncopy string a to string b:\n");
  9. copy_string(from,to);
  10. printf("string a=%s\nstring b=%s\n",a,b);
  11. return 0;
  12. }
  13. void copy_string(char from[], char to[])
  14. { int i=0;
  15. while(from[i]!='\0')
  16. {to[i]=from[i];i++;}
  17. to[i]='\0';
  18. }