Mail Archives: djgpp/1997/12/20/12:47:51
Adam Young wrote:
>
> Hello,
>
> I am developing a program that uses the parallel
> port to read a 4-bit BCD number and return the
> decimal value. I am accomplishing this by constantly
> scanning the port and checking for the strobe (DV)
> to go high. Once it goes high, the 4-bit word is
> sent to "conv" to be converted to the corresponding
> decimal value and printed to the screen. This is the
> problem. The "printf" marked with the ???? is needed
> for the numbers to be printed out "real time". If
> I do not have the "printf ("\n");" statement, the
> program only writes to the screen AFTER I hit control-c
> to stop the program. I am using DJGPP and RHIDE to
> develop this program.
>
> What I want is to print the data to the screen (and,
> later to be logged in a file) in a row (ie. "123456")
> instead of on a new line each time. I am sure this
> is not a problem with DJGPP or RHIDE but a simple
> "error" that I am making. Any help is appreciated.
> Thanks in advance!
The error is that you didn't read the FAQ, chapter
9.4. (Too bad, my newsreader refuses to post this,
so some exlplainations)
DJGPP and most other compilers under decent operating
systems make textfiles buffered, and stdio files line
buffered.Hence, something that goes to stdout
will be seen after a "\n", a certain number of characters
in the output buffer, or an fflush(stdout);
If you do not plan to redirect the screen output
to a file, it might be more efficient to use
cprintf().
--
Ciao
Tom
*************************************************************
* Thomas Demmer *
* Lehrstuhl fuer Stroemungsmechanik *
* Ruhr-Uni-Bochum *
* Universitaetsstr. 150 *
* D-44780 Bochum *
* Tel: +49 234 700 6434 *
* Fax: +49 234 709 4162 *
* http://www.lstm.ruhr-uni-bochum.de/~demmer *
*************************************************************
- Raw text -