1
0

c8-20-1.c 426 B

123456789101112131415161718
  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. printf("string a=%s\nstring b=%s\n",a,b);
  7. printf("copy string a to string b:\n");
  8. copy_string(a,b);
  9. printf("\nstring a=%s\nstring b=%s\n",a,b);
  10. return 0;
  11. }
  12. void copy_string(char from[], char to[])
  13. { int i=0;
  14. while(from[i]!='\0')
  15. {to[i]=from[i];i++;}
  16. to[i]='\0';
  17. }