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 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit Cache-Post-Path: dan.emsphone.com!-@localhost To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp bitc 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