delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/10/03:30:21

From: br5an AT aol DOT com (Br5an)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Why don't printf work properly with getch ()?
Date: 8 Oct 1997 13:52:48 GMT
Lines: 33
Message-ID: <19971008135201.JAA16622@ladder02.news.aol.com>
NNTP-Posting-Host: ladder02.news.aol.com
Organization: AOL http://www.aol.com
References: <01bcd38e$b9e2da40$0b0867d1 AT default>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Newbie wrote:

>I had some problem with printf and getch working together.
>Seems to me that the last printf preceeding a getch is executed >only after a
 key is pressed.

>examples:
>	printf ("\n1");
>	printf ("\n2");
>	printf ("\n3");
>	getch ();
>would produce
>1
>2
>waiting for keystroke, after a key is pressed
>3

Another wrote:

>This is because they're not designed to.  printf is a stdio library
>function, and getch is a conio library function.  They're not >designed to be
 used together.

>You should be using all-stdio or all-conio functions to do your job. 
>That means either using printf and getchar, or cprintf and getch,
>respectively.

     This may all be true.  With other compilers I've shamelessly mixed stdio
 and conio functions without a hitch.  But in the example above, could it just
 be another example of buffered output most of us here (at msdos.djgpp) have
 read so much about lately?

                     Sincerely, Br5an AT aol DOT com

- Raw text -


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