Path: utzoo!attcan!uunet!cs.utexas.edu!helios!diamond!jdm5548 From: jdm5548@diamond.tamu.edu (James Darrell McCauley) Newsgroups: comp.lang.c Subject: Re: execution out of order ? Keywords: stdin, getchar, stdout Message-ID: <6732@helios.TAMU.EDU> Date: 20 Jul 90 18:27:06 GMT References: <6687@helios.TAMU.EDU> Sender: usenet@helios.TAMU.EDU Reply-To: jdm5548@diamond.tamu.edu (James Darrell McCauley) Organization: Texas A&M University Agricultural Engineering Department Lines: 35 I'm an reposting this question because, as 1 of the 2 responses mentioned, I may have not made myself quite clear. Here's the code fragment: main() { ... getchar(); /* stdin, as well as stdout, are console */ printf("first line\n"); ... /* calculations - no I/O */ printf("second line\n"); getchar(); printf("third line\n"); } and script of execution: % a.out first line second line third line % I should have to press return before the first line is printed! Why does it do this? Do I have to clear the input buffer somehow? I am running SunOS 4.0.3 and I am not redirecting stdin or stdout. I have experienced the same thing using DOS. This is just a general question (not something I couldn't work around) that I don't think should be machine specific. Thanks. Darrell McCauley, jdm5548@diamond.tamu.edu (128.194.14.1) --- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - James Darrell McCauley jdm5548@diamond.tamu.edu Dept of Ag. Engineering (409) 845-6484 Texas A&M University, College Station, Texas 77843-2117, USA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -