Syntax
#include <string.h> char *strcat(char *string1, const char *string2);Description
strcat concatenates string2 to string1 and ends the resulting string with the null character.
strcat operates on null-terminated strings. The string arguments to the function should contain a null character (\0) marking the end of the string. No length checking is performed. You should not use a literal string for a string1 value, although string2 may be a literal string.
If the storage of string1 overlaps the storage of string2, the behavior is undefined.
strcat returns a pointer to the concatenated string (string1).
This example creates the string "computer program" using strcat.
#include <stdio.h>
#include <string.h>
#define SIZE 40
int main(void)
{
char buffer1[SIZE] = "computer";
char *ptr;
ptr = strcat(buffer1, " program");
printf("buffer1 = %s\n", buffer1);
return 0;
/****************************************************************************
The output should be:
buffer1 = computer program
****************************************************************************/
}
Related Information