C program to concatenate strings | CodeTextPro

Strings Concatenate

C program to concatenate two strings, for example, if the first string is "C " and the second string is " Program"  then on concatenating these two strings we get the string "C Program." To concatenate two strings we use Strcat function of string.h, to concatenate without using the library function.


C Program to concate string

Example #1:


#include<stdio.h>


#include<conio.h>

#include<string.h>

main()
{
char s1[10];

char s2[10];

printf("Enter the first string: ");

gets(s1);

printf("Enter the second string: ");

gets(s2);

strcat(s1,s2);

puts(s1);

getch();
}


Output of program:

C Program to Concatenate Two Strings










Post a Comment

0 Comments