C program to concatenate two string.

Posted by Mangesh on March 21, 2018

/* Program in C to concatenate two string. */

Description :

As an input we shall get two strings, like programming, earth and we need to concatenate this two string and form one string.
Example : string 1 => programming, string 2 => earth, result => programmingearth.

Logic :

Store both the string in a variable. For concatenation of both string we can use method from string header files by include it. ( #include<string.h> ). And then we can use the method strcat(string1, string2). By default the result will be store in first string i.e. string1.

Program :

int main()
  char a[100], b[100];
  printf("Enter the first string\n");
  printf("Enter the second string\n");
  printf("String after concatenation is %s\n",a);

Output :

C program for concatenate two string

Skills learn :

strcat function.

Written with from Mangesh.

Related Post
1 C program for naive string matching algorithm.
2 C program to check whether the given string is palindrome or not.
3 C program to concatenate two string.
4 C program to check whether two strings are anagram or not.
5 C program to reverse the string.
6 C program to replace a character in a string.
7 C program to compare two string.
8 C program to compare two string using strcmp function.
Latest Post
1 C program to implement Queue using linked list.
2 C program for binary search tree (BST).
3 C program to search an element in linked list.
4 C program for postorder traversal in binary tree.
5 C program for preorder traversal in binary tree.