1 # include <stdio. h> 2 # include <string. h> 3 # define N 5 4 5 6 char * mycpy (char * S1, char * S2) 7 {8 // array type 9/* int I; 10 while (s2 [I]! = '\ 0') {11 S1 [I] = S2 [I]; 12 I ++; 13} 14 S1 [I] =' \ 0'; 15 return S1; */16 // pointer type 17 char * P = S1; 18 while (* S2! = '\ 0') {19 * S1 = * S2; 20 S1 ++; 21 S2 ++; 22} 23 * S1 =' \ 0'; 24 return P; 25} 26 27 int main () 28 {29 char S1 [100]; 30 char S2 [100]; 31 // gets (S1); 32 // gets (S2 ); 33 fgets (S1, N, stdin); 34 if (S1 [strlen (S1)-1] = '\ n ') {// remove the linefeed 35 S1 [strlen (S1)-1] = '\ 0'; 36} 37 fflush (stdin ); // clear the buffer (for details, see the difference between gets and fgets functions) 38 fgets (S2, N, stdin); 39 if (s2 [strlen (S2) -1] = '\ n') {// remove the linefeed 40 S2 [strlen (S2)-1] =' \ 0 '; 41} 42 printf ("% s", mycpy (S1, S2); 43 44 return 0; 45}