delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/10/20/18:27:52

From: dan AT dan DOT emsphone DOT com (Dan Nelson)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Using getch() in DJGPP
Date: 20 Oct 1996 18:53:19 GMT
Organization: Executive Marketing Services, Inc.
Lines: 35
Message-ID: <845837598.241479@dan.emsphone.com>
References: <01bbbea6$206725e0$454fb7ce AT default>
Reply-To: dnelson AT emsphone DOT com (Dan Nelson)
NNTP-Posting-Host: 199.67.51.101
Mime-Version: 1.0
Cache-Post-Path: dan.emsphone.com!-@localhost
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

bitc <uh AT rt> wrote:
> Why doesn't the following function in DJGPP...
>
> int main()
> {
> 	printf("Hello.");
> 	getch();
> }
>
> Now, in every other compiler I've seen, the binary will run like this:

You mean "Now, In Turbo C," :) ...  Stdout is line-buffered, which
means you don't see printfs until a "\n" or you fflush(stdout); . 
change it to:

int main()
{
	printf("Hello.");
	fflush(stdout);
 	getch();
	return 0;
}

> Hello. {keypress}{exit}
>
> But when compiled under DJGPP, I get this:
>
> {keypress}Hello. {exit}
>
> This isn't making sense to me. Why isn't the string printing until I
> press a key? Shouldn't the program run in the order I wrote the
> instructions?
>
> Jake Harvey
> jwharvey AT interaccess DOT com

- Raw text -


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