C-programming - String concetenate in c, C program to concatenate strings

String concetenate in c

This program concatenates strings, for example if the first string is "hello" and second string is "world" then on concatenating these two strings we get the string "helloworld". To concatenate two strings we use strcat function of string.h.


#include<stdio.h>
#include<conio.h>
#include<string.h>
 
main()
{
   char a[100], b[100];
 
   printf("Enter the first string\n");
   gets(a);
 
   printf("Enter the second string\n");
   gets(b);
 
   strcat(a,b);
 
   printf("String obtained on concatenation is %s\n",a);
 
   getch();
   return 0;
}


output


Enter the first string
compound
Enter the second string
interest
String obtained on concatenation is
compound interest



The topic on C-programming - String concetenate in c is posted by - Maha

Hope you have enjoyed, C-programming - String concetenate in cThanks for your time

Tech Bluff