delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/28/11:35:03

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Begginer problems with C & DJGPP
Date: Sat, 27 Dec 1997 16:57:28 -0500
Organization: Two pounds of chaos and a pinch of salt.
Lines: 40
Message-ID: <34A579C8.6B72@cs.com>
References: <682ti1$keq$1 AT svr-c-02 DOT core DOT theplanet DOT net>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp213.cs.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019