Strcat function in C
The char * strcat function (char * dest, const char * src) append the string pointed to by src, at the end of the string pointed to by dest.
Declare the function strcat in C
Below is the declaration for strcat () in C:
char * strcat ( char * dest , const char * src )
Parameters
dest - This is the pointer to the destination array, which: should contain a string and should be large enough to contain the result string after being concatenated.
src - This is the string to be appended (append) at the end. This string should not overlap (stack) on the target string.
Returns the value
This function returns a pointer to the dest result string.
For example
The following C program illustrates the usage of strcat () in C:
#include #include int main () { char src [ 50 ], dest [ 50 ]; strcpy ( src , "Day la chuoi source (chuoi src)" ); strcpy ( dest , "Day la chuoi destination (chuoi dest) " ); strcat ( dest , src ); printf ( "Sau khi thuc hien ham strcat, chuoi dest la: n|%s|" , dest ); return ( 0 ); } Compiling and running the above C program will result:
According to Tutorialspoint
Previous lesson: memset () function in C
Next lesson: strncat () function in C