Concatenate Two String using STRCAT() – C Program

STRCAT() Function – C Program

In previous C program post we have done the concatenate two string without using STRCAT function.

STRCAT() Function – The STRCAT() Function used to join second string to at the end of first string.

The Syntax of STRCAT() Function :

strcat(str1, str2) – str2 is concatenated at the end of str1.
strcat(str2, str1) – str1 is concatenated at the end of str2.

Example of STRCAT() Function C Program

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

int main()
{
 char str1[100], str2[100];

 printf("Please, enter the first string = ");
 gets(str1)

 printf("\nPlease, enter the second string = ");
 gets(str2)

strcat(str1,str2)
 
 printf("\nThe concatenate string is = %s",str1);

 return 0;
}

The Output of STRCAT C Program is :

Please, enter the first string = C
Please, enter the second string = Program

The concatenate string is = CProgram

Above STRCAT() C Program we have given two string “C” and “Program”, the output of concatenated string is : “CProgram”.

Leave a Reply

Your email address will not be published. Required fields are marked *