strcat function(String Concatenation) in C Language – example and detail

In the C Programming Language, the strcat characteristic appends a replica of the string pointed to via s2 to the cease of the string pointed to via s1. It returns a pointer to s1 the place the ensuing concatenated string resides.


The syntax for the strcat feature in the C Language is:

char *strcat(char *s1, const char *s2);

Parameters or Arguments

s1 A pointer to a string that will be modified. s2 will be copied to the give up of s1. s2 A pointer to a string that will be appended to the end of s1.


The strcat function returns a pointer to s1 (where the resulting concatenated string resides).

Required Header

In the C Language, the required header for the strcat function is:

#include <string.h>

Note Use the strcat characteristic with warning as it is handy to concatenate extra bytes into your variable the usage of the strcat function, which can motive unpredictable behavior.

Applies To

In the C Language, the strcat characteristic can be used in the following versions:

ANSI/ISO 9899-1990

strcat Example

Let’s seem to be at an example to see how you would use the strcat feature in a C program:

/* Example using strcat by */

#include <stdio.h>
#include <string.h>

int main(int argc, const char * argv[])
   /* Define a temporary variable */
   char example[100];

   /* Copy the first string into the variable */
   strcpy(example, " ");

   /* Concatenate the following two strings to the end of the first one */
   strcat(example, "is over 10 ");
   strcat(example, "years old.");

   /* Display the concatenated strings */
   printf("%s\n", example);

   return 0;

When compiled and run, this application will output: is over 10 years old.

Similar Functions

Other C functions that are similar to the strcat function:

strncat function <string.h>