www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/12/07:23:13

Date: Wed, 12 Aug 1998 13:22:40 +0200
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Message-Id: <199808121122.NAA14739@acp3bf.physik.rwth-aachen.de>
To: orichman AT hotmail DOT com (Oliver Richman)
Cc: djgpp AT delorie DOT com
Subject: Re: conio and stdio
Newsgroups: comp.os.msdos.djgpp
Organization: RWTH Aachen, III. physikalisches Institut B

In article <35d16369 DOT 13894854 AT news DOT pathcom DOT com> you wrote:

> I don't see why

> 	fflush(stdout);
> 	gotoxy(1,1);
> 	printf("moo");
> 	fflush(stdout);

> won't work. In fact as long as the functions are implemented properly,
> it *must* work. I think. 

You may think so. But even DOS thinks otherwise, and so does DJGPP,
too :-)

stdio is a concept that simply doesn't fit together with 'put a
character on screen *here*, and another one in green *there*...'.  A
proper implementation of printf() works on something called a
*stream*, which is completely one-dimensional, and strictly defined by
the ANSI standard. Thus, stdio is close to 100% portable from any kind
of computer to any other. <conio.h> is not even portable from DOS to
Windows, not even to speak any system not based on Intel processors.

Being single-dimensional implies no gotoxy, no colors, nothing. Just
characters written out one after the other (with the occasional
newline to structure them). stdio streams are meant not just for
screens, as well. You're supposed to catch them and write them to a
file, instead, which you can later read back in, if you want. Now,
what would you expect to find in such a file, for a string printed in
green with a red background, at position 50,30 on a 80x60 screen?  And
what is supposed to happen if you read it back in, but the screen is
only 80x25, now?

But you're lucky: there's 'cprintf()' for you, so you can use most of
printf()'s functionality, even in console I/O.

--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


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