Life without fflush(stdin)
Hey guys,
I have been using fflush(stdin) since I started programming, when I came across this site, I found out fflush(stdin) is wrong to use. When I don't use fflush(stdin), the program sometimes doesn't even wait for user to input some text, eg:
Code:
printf("Title: ");
fgets (cds[count].title,200,stdin);
printf("Artist: ");
fgets (cds[count].artist,200,stdin);
When the code is executed it doesn't waits for the user to input title;
Especially when something is in a loop it will ask for user input the first time, then the second time it wouldn't ask for input, third time it will ask again. So is there any other solution to this?
P.S: I am using Dev-cpp, in case if the IDE matters.