In c++ you can clear out the io stream with the cin.ignore(). What do you use with scanf()? my problem is when a user enters in two numbers (space between numbers) when prompted for one. The second number is picked up by the next scanf()....I want to clear it out of the stream! Any ideas?
simple example:
#include <cstdio>
int main ()
{
int num=0;
while (true)
{
printf("enter number (-1 to exit)\n");
scanf("%d", &num);
if (num==-1)
break;
printf("entered = %d \n", num);
}
return 0;
}