Re: need some help with I/O
From: Floyd Davidson (floyd_at_barrow.com)
Date: 11/19/03
- Next message: Lorenzo J. Lucchini: "Re: Pointing to high and low bytes of something"
- Previous message: Andreas Schwab: "Re: Function declarations/defaults"
- In reply to: Irrwahn Grausewitz: "Re: need some help with I/O"
- Next in thread: Sheldon Simms: "Re: need some help with I/O"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 18 Nov 2003 14:37:35 -0900
Irrwahn Grausewitz <irrwahn33@freenet.de> wrote:
>"Les Coover" <lcc66604@cox.net.spam> wrote:
>
>> Works on MS-DOS using control-c or control-z but not on
>> UNIX using control-d or control-c
>>
>> I will work on a graceful way to exit the loop.
>
>That's definitely the best way to deal with the problem. And
>when you're done you can forget about the call to fflush; when
>the fclose is reached after exiting the loop, the output buffer
>will automatically be flushed.
I'm not sure I'd agree with that. As long as it is possible for
a user to abort the program with ^C, it *will* happen.
Providing a graceful exit from the loop may greatly reduce the
frequency, but it will still happen and defensive programming
would be to provide for that event too.
Hence, yes add a graceful way to exit the loop, but either leave
the fflush or change the buffering mode to line buffering. (No
buffering would work, but it will 1) thrash the disk and 2) has
no advantage since the input is also buffered, which prevents
any pending characters on an uncompleted line from being written
anyway.)
-- Floyd L. Davidson <http://web.newsguy.com/floyd_davidson> Ukpeagvik (Barrow, Alaska) floyd@barrow.com
- Next message: Lorenzo J. Lucchini: "Re: Pointing to high and low bytes of something"
- Previous message: Andreas Schwab: "Re: Function declarations/defaults"
- In reply to: Irrwahn Grausewitz: "Re: need some help with I/O"
- Next in thread: Sheldon Simms: "Re: need some help with I/O"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|