C Program to Concat Two Strings with using Library Function
Concat Two Strings Using Library Function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#include<stdio.h> #include<string.h> int main() { char str1[100]; char str2[100]; char str3[100]; int len; printf("\nEnter the String 1 : "); gets(str1); printf("\nEnter the String 2 : "); gets(str2); strcpy(str3, str1); strcat(str3, str2); printf("\nConcated String : %s", str3); return (0); } |
Explain me ?
- Copy “str1” into “str3”.
- Then Concat “str2” to “str3” , after concating result will be stored in “str3”
- strcat,strcpy functions are included in Header File : string.h
Functions Required :
- gets : For Accepting String
- strcpy : String Function for Copy one string into other
- strcat : String Function for Concating two Strings