Mail Archives: djgpp/1997/12/28/11:35:03
Mark Whalebelly wrote:
>
> HI everyone,
>
> I've been working my way through the C for dummies books ,
> The problem I sometimes get is when I copy a program from
> the book and run the program any characters displayed on the
> screen don't appear untill the program has ended.
>
> dropnuke.c in "C for Dummies volume 2" is the best example.
>
> Hope someone can help.
Standard output is line-buffered by default in DJGPP. For more
information, look at chapter 9.4 of the DJGPP Frequently Asked Questions
list (v2/faq210b.zip from SimTel or online at
http://www.delorie.com/djgpp/v2faq/).
The short solution: to get a program to display buffered output, do one
of the following:
1) Print a newline.
2) Call a stdio input function (scanf(), getchar(), gets()).
3) Call fflush( stdout ).
4) Turn off buffering with setbuf( stdout, NULL ).
_C for Dummies_ is not the greatest of tutorials; I read the first book
as a lark and was not impressed. While it may provide a relatively
painless introduction to C, it glosses over a great many rules in the
process. One of my biggest pet peeves about _C for Dummies_ is that it
advocates the use of 'void main()' without telling readers that it's a
bad idea.
--
---------------------------------------------------------------------
| John M. Aldrich | "History does not record anywhere at |
| aka Fighteer I | any time a religion that has any |
| mailto:fighteer AT cs DOT com | rational basis." |
| http://www.cs.com/fighteer | - Lazarus Long |
---------------------------------------------------------------------
- Raw text -