Concatenating two
strings into a third system
Program
#include<stdio.h>
void main()
{
char str1[40],
str2[40], str3[81];
int k = 0, j = 0;
printf ("\nEnter
The First String : ");
scanf
("%s", str1);
printf ("\nEnter
The Second String : ");
scanf
("%s", str2);
for (k = 0; str1[k]
!= '\0'; k++)
str3[k] = str1[k];
for (j = 0; str2[j]
!= '\0'; j++, k++)
str3[k] = str2[j];
str3[k] = '\0';
printf ("\nThe
Two Stings Are : \n\n%s \t %s\n\n", str1, str2);
printf ("\nThe
Concatenated Sting is : %s", str3);
}
No comments:
Post a Comment