+ 1

C language how concatenate 2 strings in another string to printf out?

hello guys i need to concatenate 2 strings in another string and use it to printf out char str1[20]; char str2[20]; char str3[40]; printf("type some txt"); scanf("%s", str1); printf("again"); scanf("%s", str2); // now I need to printf both strings in char str3[]; I know there are other ways to concatenate but I need to understand how I can do this one I neeed a var for str3? I need an operator? thank u all , have nice day

5th Oct 2017, 4:16 PM
dimitriDV
dimitriDV - avatar
1 Answer
+ 3
C has tools for that in string.h! #include <string.h> strcpy(str3, str1); // copy str1 into str3 strcat(str3, str2); // append str2 to str3
5th Oct 2017, 4:26 PM
Schindlabua
Schindlabua - avatar