STRCAT() FUNCTION

The function strcat() concatenates two strings.

In C programming, strcat() concatenates (joins) two strings. The strcat() function is defined in <string.h> header file.

Syntax:

char *strcat(char *dest, const char *src) 

It takes two arguments, i.e, two strings or character arrays, and stores the resultant concatenated string in the first string specified in the argument. The pointer to the resultant string is passed as a return value.



1A_Pro20: W.A.P. to perform strcat() function on string.
#include<stdio.h>
#include<string.h>
void main()
{
          char str1[]="This is ", str2[]="computer programming";
          //concatenates str1 and str2 and resultant string is stored in str1.
          strcat(str1,str2);
          
          puts(str1);
          puts(str2);
          getch(); 
}


Output: