implement two strings connected
1#include <stdio.h>2#include <string.h>3 4 //connect the source string to the destination string5 Char*STRCAT1 (Char*dest,Const Char*src)6 {7 intI=0;8 intn=strlen (dest);9 Ten if((dest! = null) && (src! = null))//the source pointer and the destination pointer cannot be null One { A for(i=0; Src[i]! =' /'; i++) - { -Dest[n+i] =Src[i]; the } -Dest[n+i] =' /'; - } - + returndest; - } + A //from the source string, even a few characters into the destination string at Char*STRCAT2 (Char*dest,Const Char*SRC,intnum) - { - intI=0; - intn=strlen (dest); - - if((dest! = null) && (src! = null))//the source pointer and the destination pointer cannot be null in { - for(i=0; I<num && src[i]! =' /'; i++) to { +Dest[n+i] =Src[i]; - } theDest[n+i] =' /'; * } $ Panax Notoginseng returndest; - } the + A intMain () the { + Chara[ -]="Hello"; - Char*p="world!123"; $ //testing the STRCAT1 function $ STRCAT1 (a,p); -printf"After strcat1 function,a=%s\n", a); - the //testing the STRCAT2 function - Charb[ -]="beautiful";WuyiSTRCAT2 (B,p,6); theprintf"After strcat2 function,b=%s\n", b); - Wu return 0; -}
Implement STRCAT functionality