Flush the output stream before calling scanf.
Code:
int a, b;
printf("Enter 2 numbers:");
fflush( stdout );
scanf("%d %d", &a, &b);
printf("%d %d", a, b);
If you print with a newline at the end, it will flush the output. Without, it may or may not. It doesn't have to. So it's really dependant on your OS / compiler / whatever it feels like.
Code:
printf("foo\n"); /* flushes output... */
printf("bar" ); /* doesn't */
fflush is only designed for output streams. You can't flush input with it. Or rather, it's undefined behaviour if you try it.
Quzah.