Function name : strcat
Header file : <string.h>
Function : Splice a string after the target string
Function prototype : char *strcat(char *destin, const char *source);
Function : Splice a string after the target string
Parameters : char *destin is the target string array
const char *source is the string array to be spliced
Return value : Returns the pointer to the string array after successful splicing.
Note : Destin must be large enough to accommodate the source, otherwise an overflow error will occur. This function does not generate a new string, but modifies the original string. Therefore, destin can only be a character array, not a string pointed to by a string pointer, because the string pointer points to a string constant, and the constant cannot be modified.
Program example: Concatenate strings to form a new string, and output the new string
#include<string.h>#include<stdio.h>intmain(void){chardestination[25]={Ilove};char*blank=,*c=www.dotcpp.com;strcat(destination,blank);strcat (destination,c);printf(%sn,destination);return0;}
Running results:
Ilovewww.dotcpp.com