Pages

How to combine two strings

//How to combine two strings.

#include<stdio.h>
#include<conio.h>

void main()
{
  char str1[100],str2[100];
  clrscr();
  printf("Enter first string:");
  gets(str1);
 
  printf("Enter second string:");
  gets(str2);
 
  strcat(str1,str2);
 
  printf("After concatenation of string is: %s\n",str1);
 
  getch();
}

Output:

Enter first string:My name
Enter second string:is abc.
After concatenation of string is: My nameis abc.

No comments:

Post a Comment