I want to concat two strings from the user's keyboard input, and this is the code I tried :
char a[50], b[50], aAndB[100];
printf("\na : ");
fgets(a, sizeof(a), stdin);
printf("\nb : ");
fgets(b, sizeof(b), stdin);
snprintf(aAndB, sizeof(aAndB), "%s/%s", a, b);
printf(aAndB);
The problem is that the two strings are concatenated with a "\n", to be more clear, this is the output :
a : text1
b : text2
text1
/text2
but the output I'm expecting is :
a : text1
b : text2
text1/text2
How can I solve this problem ?