Article View: comp.sys.amiga.tech
Article #5240Re: testing DICE 2.05
From: Matthew Dillon
Date: Tue, 11 Sep 1990 16:11
Date: Tue, 11 Sep 1990 16:11
54 lines
2638 bytes
2638 bytes
>In article <11479@ddnvx1.afwl.af.mil> RIDOUT@ddnvx1.afwl.af.mil writes:
>The following is a little program I used while testing out DICE 2.05.
>I added the fflush(stdout) call to make this work the way I thought is should
>in the first place. Is I looked through the library source I found notes on
>how Matt uses a double buffer for output. My question is am I handleing this
>correctly or am I suposed to use a setvbuf call some how to make this work.
>Using setvbuf all I was able to accomplish is locking up my shell.
>This is DICE 2.05 unregistered if it makes a difference.
Actually, it doesn't lock up your shell, but using setvbuf() to make
the console unbuffered leaves it that way when the program exits unless
you re-buffer it before exiting. control-J still works on the shell
though returns are screwed up.
>The output without the fflush call lookes like the following:
>
>> test
>12
>2
>Enter the speed in MPH: Enter the number of hours: Miles traveled = 24
DICE does not automatically flush stdout when stdin is read. I am not
sure how standard this is even though UNIX C does this and, apparently,
Lattice and Manx do as well. I have come across several compilers that
do not do the auto-flush and cannot find any ANSI reference so... what
is right?
The whole problem occurs when you do not write out a newline to stdout
(which forces a flush)... in many cases, such as the program you outlined,
you do not want to write out a newline but do want to flush the stdout
buffer, and this is where the 'hack' comes into play (the auto-flushing
when you read from stdin).
>Thanks for any help.
Basically, just keep the fflush()'s in. It is the most portable way of
doing things.
>-
>****************************************************************************
>* Brian Ridout Internet: ridout@ddnvx1.afwl.af.mil *
>* wl/scev *
>* Kirtland AFB NM 87117 My Apple is better than your Orange. *
>****************************************************************************
--
-Matt
Matthew Dillon dillon@Overload.Berkeley.CA.US
891 Regal Rd. uunet.uu.net!overload!dillon
Berkeley, Ca. 94708
USA
Technical Details
Message-ID:
<dillon.5926@overload.Berkeley.CA.US>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!overload!dillonReferences:
<11479@ddnvx1.afwl.af.mil>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!overload!dillon From: dillon@overload.Berkeley.CA.US (Matthew Dillon) Newsgroups: comp.sys.amiga.tech Subject: Re: testing DICE 2.05 Message-ID: <dillon.5926@overload.Berkeley.CA.US> Date: 11 Sep 90 16:11:32 GMT References: <11479@ddnvx1.afwl.af.mil> Lines: 54