Code 1:-
int main()
{
char str[200];
fgets(str,200,stdin);
printf("%s",str);
return 0;
}
Output:-
ab cd
ab cd
(line feed)
Code 2:-
int main()
{
char str[200];
gets(str);
printf("%s",str);
return 0;
}
Output:-
ab cd
ab cd
When I enter ab(space)cd(enter key)
, then in case of fgets()
I am getting a line feed
in the output, whereas in case of gets()
, no new line feed is displayed.
What is the matter of the line feed
in this case.