it seems not probable to flush either input buffer or output buffer. Keyboard mayb implemented using i/o port 0x60 and 0x64. I do not remember there is any commands which can b issued to flush the buffer, so I do not think the related API exists. But mayb u can first disable the keyboard then enable it to flush both buffers.
/* Read each word as a string. */
printf( "Enter a sentence of four words with scanf: " );
for( integer = 0; integer < 4; integer++ )
{
scanf( "%s", string );
printf( "%s\n", string );
}
/* You must flush the input buffer before using gets. */
fflush( stdin );
printf( "Enter the same sentence with gets: " );
gets( string );
printf( "%s\n", string );
}
Output
Enter a sentence of four words with scanf: This is a test
This
is
a
test
Enter the same sentence with gets: This is a test
This is a test