C Program String Concatenation using strcat

By | March 12, 2020

C Program String Concatenation using strcat

/*
C program to input two strings 
and concatenating the second string at 
end of first string using strcat()
predefined string function.
*/

#include <stdio.h>
#include <string.h>
int main()
{
  char str1[100], str2[100];

  printf("Enter the first string\n");
  gets(str1);

  printf("Enter the second string\n");
  gets(str2);

  strcat(str1, str2);

  printf("String obtained after concatenation\nusing strcat() function is: %s\n", str1);

  return 0;
}

Output

Enter the first string
easycodebook.com
Enter the second string
101 Important C Programs
String obtained after concatenation
using strcat() function is: easycodebook.com 101 Important C Programs

 

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *