Complete code:
1 # include <stdio. h> 2 # include <string. h> 3 # include <malloc. h> 4 5 # define true 1 6 # define false 0 7 8 char * 9 strca (char *, char *); 10 11 char * 12 join1 (char *, char *); 13 14 int15 main (void) {16 char * A = "hello"; 17 char * B = "de Me "; 18 printf ("% s \ n", strca (A, B); 19} 20 21 char * 22 strca (char * des, char * SRC) {23 char * r = (char *) malloc (sizeof (strlen (DES) + sizeof (strlen (SRC) + 1); // The tail is stored in '\ 0'. Terminator. 24 if (! R) {25 printf ("out of memory! \ N "); 26 return false; 27} 28 char * TMP = r; // Save the first address. 29/* While (* r ++ = * des ++) 30 */; 31 32 While (* des) 33 * r ++ = * des ++; 34 35 while (* r ++ = * SRC ++) 36; 37 return TMP; 38}
I am playing C basics recently, but I haven't fully understood the comment section of strca function (29th ~ 30 rows) Why can't the code achieve the desired effect? I started to study disassembly of X86 and C in the past two days. I have little information in China, and I am a little busy with the recent postgraduate review. Come on.
C String concatenation.