Format
#include <string.h> char *strcat(char *string1, const char *string2);
Language Level: ANSI, POSIX, XPG4
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.
Return Value
strcat returns a pointer to the concatenated string (string1).
Example
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 *************************************/ }
![]()
strchr -- Search for Character
strcmp -- Compare Strings
strcpy -- Copy Strings
strcspn -- Compare Strings for
Substrings
strdup -- Duplicate String
stricmp -- Compare Strings as Lowercase
strncat -- Concatenate Strings
strncmp -- Compare Strings
strnicmp -- Compare Strings Without Case
Sensitivity
wcscat -- Concatenate Wide-Character
Strings
wcsncat -- Concatenate Wide-Character
Strings
<string.h>