[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using fflush(stding)
>Why do you use fflush for input stream ???
I thought that fflush can flush input streams too? (I do it when
programming in DOS/WINDOWS.)
Now I understand that the input data is still in the terminal's buffer and
has not been passed to stdin. My question is, does anyone know how to flush
data from the terminal's buffer?
> {
> puts("Enter String:");
> scanf("%10s",buf1);
> if(!fflush(stdin))
> perror("PROBLEM WITH FFLUSH");
>
> puts("Enter another String:");
> scanf("%!0s",buf2);
> if(!fflush(stdin))
> perror("PROBLEM WITH FFLUSH");
>
> printf("***%s*** ***%s***\n",buf1,buf2);
>}
>
>The problem is that with input that exceeds 10 chars, buf2 gets the
reminder
>of the input.
>The error printed by perror is "seek error".
>
>Now, I understand that probably the terminal did not pass all of the chars
>to stdin thus fflush canno't flush them?
>
>Can someone comment?
>
> Yoni Nazarathy
>
>
>
>
=================================================================
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il