Write your own strcat function ------ → MyCat
1 # include <stdio. h> 2 # include <string. h> 3 # define N 5 4 5 char * MyCat (char * S1, char * S2) 6 {7 // array type 8/* int I = 0; 9 While (S1 [I]! = '\ 0') {10 I ++; 11} 12 Int J = 0; 13 while (s2 [J]! = '\ 0') {14 S1 [I] = S2 [J]; 15 I ++; 16 J ++; 17} 18 S1 [I] = '\ 0'; 19 20 return S1; */21 // pointer type 22 char * P = S1; // define the struct pointer P pointing to S1 23 while (* S1! = '\ 0') {// point S1 to' \ 0' 24 S1 ++; 25} 26 while (* S2! = '\ 0') {// connect S2 to 27 * S1 = * S2; 28 S1 ++; 29 S2 ++; 30} 31 * S1 = '\ 0'; // Let S1 end with' \ 0' 32 33 return P; 34 35} 36 37 int main () 38 {39 char S1 [N]; 40 char S2 [N]; 41 fgets (S1, N, stdin); 42 if (S1 [strlen (S1) -1] = '\ n') {// remove the linefeed 43 S1 [strlen (S1)-1] =' \ 0'; 44} 45 fflush (stdin ); // because fgets is used above, we need to clear the buffer here (for details, see the difference between gets and fgets functions) 46 fgets (S2, N, stdin ); 47 If (s2 [strlen (S2)-1] = '\ n') {// remove the linefeed 48 S2 [strlen (S2)-1] =' \ 0 '; 49} 50 printf ("% s", MyCat (S1, S2); 51 // printf ("% s \ n % s", S1, S2 ); 52 53 return 0;