www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/11/13/06:29:34

Xref: news-dnh.mv.net comp.os.msdos.djgpp:3183
Path: news-dnh.mv.net!mv!news.sprintlink.net!in2.uu.net!fdn.fr!jussieu.fr!cea.fr!JUPITER!nicolas
From: nicolas AT jupiter DOT ceng DOT cea DOT fr (Eric NICOLAS)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: stupid C question
Date: 13 Nov 1995 10:12:20 GMT
Organization: Commissariat a l'energie atomique
Lines: 26
Distribution: world
References: <DHz3vA DOT 245 AT jade DOT mv DOT net>
Reply-To: nicolas AT jupiter DOT ceng DOT cea DOT fr
Nntp-Posting-Host: jupiter.ceng.cea.fr
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Dj-Gateway: from newsgroup comp.os.msdos.djgpp

> I find that when I do a printf, or putchar, nothing appears on the screen
> until I send a "\n" to standard output

Yes, this is a matter of flush. The problem is that djgpp is ported from
an U..X compiler. And, under U..X, all outputs goes into a buffer until
a EndOfLine. So nothing comes to screen until '\n' char. This is the
right way to use stdout. DOS is another time wrong :(

The solution is to tell the output file to release the buffer. This can
be done with a fflush(stdout);

So, the equivalent of :
	printf("Hello. Begining process...");
	/* ... Processings ... */
	printf("End process.\n");

in 'dos'-C (I mean TurboC, ZorthecC...), is :
	fprintf(stdout,"Hello. Begining process..."); fflush(stdout);
	/* ... Processings ... */
	fprintf(stdoutm"End process.\n");

in 'good' C (And djgpp is a good C compiler).

Hope it helps,
Eric.

- Raw text -


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