#include<stdio.h>
int main()
{
char str[100];
printf("Enter a string: ");
fgets(str, sizeof(str), stdin);
fputs("Liverpool", stdout);
fputs("Manchester", stdout);
return 0;
}
OUTPUT
Enter a string : punch
LiverpoolManchester
But, when I am taking the input from the user, it is not giving the expected output.
#include<stdio.h>
int main()
{
char str[100];
printf("Enter a string: ");
fgets(str, sizeof(str), stdin);
fputs(str, stdout);
fputs(str, stdout);
return 0;
}
OUTPUT
Enter a string : punch
punch
punch
The only change between the two codes is, I was specifying the string in the previous one and in the latter, I am taking the input from the user. Can anybody tell me the reason behind this ??