# include void copy_string ( char *to, char *from ); int main ( ) { char s1[] = "Charles"; char s2[80] = "William"; char *s3 = "Frank"; printf ( " S1 = \"%s\".\n", s1 ); printf ( " S2 = \"%s\".\n", s2 ); printf ( " S3 = \"%s\".\n", s3 ); copy_string ( s2, s1 ); printf ( "\n" ); printf ( "After call to copy_string(s2,s1):\n" ); printf ( "\n" ); printf ( " S1 = \"%s\".\n", s1 ); printf ( " S2 = \"%s\".\n", s2 ); printf ( " S3 = \"%s\".\n", s3 ); copy_string ( s2, s3 ); printf ( "\n" ); printf ( "After call to copy_string(s2,s3):\n" ); printf ( "\n" ); printf ( " S1 = \"%s\".\n", s1 ); printf ( " S2 = \"%s\".\n", s2 ); printf ( " S3 = \"%s\".\n", s3 ); return 0; } void copy_string ( char *to, char *from ) { for ( ; *from != '\0'; from++, to++ ) { *to = *from; } *to = '\0'; }