0

Hello,

My problem is like that when I scan the data using fgets function and after I put fflush function but compiler not
wait for taking a data and it is directly go in next value scan.How to solve my program?

4
Contributors
5
Replies
23
Views
3 Years
Discussion Span
Last Post by Assembly Guy
0

Sometime compiler not wait for taking input from 1st fgets function.
And it skipped it.
I put fflush(stdin) after fgets function but still it is not working.
I have used multiple time fgets function in my program,so how to solve this problem.
Give suggetion.

#include<stdio.h>
main()
{
   char a[300];
   fgets(a,300,stdin);
   printf("A=%s \n",a);
   fgets(a,300,stdin);
   printf("B=%s \n",a);
}
0

What compiler are you using, and how are you running it?

For what it's worth, I'll put my money on Turbo C; that typeless main whispers it.

Also works as expected here using GCC 4.8.2 20140206 (prerelease).

Edited by Assembly Guy

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.