www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/23/17:30:35

From: hat AT se-46 DOT wpa DOT wtb DOT tue DOT nl (Albert Theo Hofkamp)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Problem :)
Date: 23 Sep 1997 09:16:40 GMT
Organization: Eindhoven University of Technology, The Netherlands
Lines: 73
Message-ID: <6081do$j56@tuegate.tue.nl>
References: <342765F1 DOT 658B AT sysop DOT com>
Reply-To: a DOT hofkamp AT wtb DOT tue DOT nl
NNTP-Posting-Host: se-46.wpa.wtb.tue.nl
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <342765F1 DOT 658B AT sysop DOT com>,
	turrican AT sysop DOT com writes:
> {
>     printf("This is the Start");
> 
>     delay("1000");
> 
>     printf("... and this is the End");
> 
> return 0;
> }
> 
> the problem is that when I m running this prog the command delay is
> executed first!?! and when delay finished I see the two printf together 
> at the end!!! Why this is happening??? I thought that dgjpp executes in
> order... I noticed also that the same thing happend to linux gcc...

It does.
The stdout is buffered inside the C program, until you either print enough
data to overflow the buffer, or until you output a newline.

> I have also borland's c++ but here this program works fine!
Borland does not care about performance, or buffering, and outputs each
character immediately.

> How can I solve that? Is this a bug? 

On Linux (and probably djgpp), disable the buffering.

No it is not a bug, it is documented behaviour. If you don't read the
manual, that doesn't make the compiler buggy !!

> I send before an email to dj Delorie 
> and said to do this thing 
> 
>> printf("This is the Start");
> 
>> Add \n or fflush(stdout) here.  Output is buffered and not written
>> until the end of line.

And he is right.

> but this is not good if I have to do this thing for every printf and
> delay
> I have to use in my program... and why in borland's c++ works
> fine???????

So why not use Borland if that compiler is better ? We don't care.
But please don't assume that a commercial compiler is better because it
behaves more like you want.

> Also I want to ask another two questions.
> 
> 1) Allegro is ported for other languages? or is only for djgpp?

djgpp is not a language.
as far as I know, it works for djgpp only, but if you want to know, you
should read the manual of allegro.

> 
> 2) I m looking for a list that contains all aditional libraries for
> djgpp
> with descriptions for each one so I can choose the best for my needs.

look at the files in www.delorie.com/pub/djgpp/v2*
That is everything which is part of the djgpp distribution.

Otherwise try a search on `library' and `djgpp' on the net :-)


Albert
---
Freedom: A Linux-based GNU computer system

- Raw text -


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