[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using fflush(stding)



Hi,
 
    Consider the following code:
 
    {
        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