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:
#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