C program to concatenate strings | CodeTextPro - CodeTextPro | Free Web Tutorial

Codetextpro Provides free Web tutorial, HTML, CSS, C, C++, Java, JavaScript, PHP, MySql, Python, Program, Programming Notes, Programming Questions and more.

Programming

Thursday, January 24, 2019

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










1 comment: