C Program to Concatenate String

To concatenate or to append one string to another string in C programming, you have to ask to the user to enter the two string and start concatenating one string into other using strcat() function.

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
    clrscr();
    char str1[50], str2[50];
    printf("Enter first string : ");
    gets(str1);
    printf("Enter second string : ");
    gets(str2);
    strcat(str1, str2);
    printf("String after concatenation is %s",str1);
    getch();
}

Run: 

 

No comments:

Post a Comment

100 C Programs with Code and Output

Program 1: C Program To Read Two Numbers And Print The Sum Of Given Two Numbers. Program 2: C Program To Read Three Numbers And Prin...