Re: need some help with I/O

From: Floyd Davidson (floyd_at_barrow.com)
Date: 11/19/03


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


Relevant Pages

  • Re: need some help with I/O
    ... "Les Coover" wrote: ... > I will work on a graceful way to exit the loop. ...
    (comp.lang.c)
  • Re: Infinite Loops and Explicit Exits
    ... > CS> One of these proposals relaxes the current restriction that an EXIT ... > termination of the loop is not visible at that point. ... > terminating condition is visible in that context. ... > You now want to allow this remote procedure, ...
    (comp.lang.cobol)
  • Re: Houston-related rants was Re: forced merges/inside lane merges/AASHTO "tapered merges"
    ... >> Are you sure about the North Loop and I-45? ... >> in particular the westbound exit for Fondren/Gessner. ... How could HCTRA put an exit ramp for eastbound ... and the West Houston Center Blvd exit still shows Old Westheimer ...
    (misc.transport.road)
  • Re: Strategies with SPARK which does not support exceptions
    ... The only way of interrupting a code sequence in SPARK is the exit ... pass' loop with an unconditional exit at the end. ...    Some complicated code that might set OK; ...
    (comp.lang.ada)
  • Re: Exit Do
    ... I've been instructed by a dot net / asp programmer that Exit Do is ... I am using nested loops and need to exit out of one loop into ... If Some Reason to stop loop then Exit Do ... Code Stage B ...
    (microsoft.public.scripting.vbscript)