Newsgroups: comp.os.msdos.djgpp From: fredex AT fcshome DOT stoneham DOT ma DOT us Subject: Re: Simple Getch problem Organization: Absolutely None! Message-ID: References: <5783b1$gbk AT yama DOT mcc DOT ac DOT uk> Date: Sun, 24 Nov 1996 12:52:21 GMT Lines: 55 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Mr David Potts (mfepsdp AT hero DOT mcc DOT ac DOT uk) wrote: > ... found the following odd behavior. > > #include > #include > int main(void) > { > printf("Before getch"); > getch(); > return(0); > } > But when I ran it, it waited for a key press *then* printed > the text rather than the other way round. What is going on? Nothing the least bit odd here. Printf is part of the stdio package which provides BUFFERED I/O. As such there is nothing in your program to force the buffering mechanism to flush the buffered data to the output device (i.e., the screen). Try adding: fflush (stdout); before the getch(). Fred -- ------------------------------------------------------------------------------- .---- Fred Smith / Office: fred AT computrition DOT com ( /__ ,__. __ __ / __ : / 508-663-2524 / / / /__) / / /__) .+' Home: fredex AT fcshome DOT stoneham DOT ma DOT us / / (__ (___ (__(_ (___ / :__ 617-438-5471 -------------------------------- Jude 1:24,25 ---------------------------------