From: "Mikkel R. Jakobsen" Newsgroups: comp.os.msdos.djgpp Subject: Re: Using getch() in DJGPP Date: Fri, 25 Oct 1996 16:11:23 +0200 Organization: University of Copenhagen Lines: 34 Sender: kroll AT ivalde DOT diku DOT dk Message-ID: <3270CA8B.41EE@diku.dk> References: <01bbbea6$206725e0$454fb7ce AT default> NNTP-Posting-Host: ivalde.diku.dk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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: > > 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 DJGPP is a DOS port of the GNU C compiler that has roots in the Unix domain. Here, output to stdio will not be printed before a newline character is sent. The program int main() { printf("Hello.\n"); getch(); } should produce the sequence you expected. Mikkel