execution out of order ?

James Darrell McCauley jdm5548 at diamond.tamu.edu
Sat Jul 21 04:27:06 AEST 1990


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
        <hit return>
        <hit return again>
        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 at diamond.tamu.edu (128.194.14.1)
--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
James Darrell McCauley                 jdm5548 at diamond.tamu.edu
Dept of Ag. Engineering                          (409) 845-6484
Texas A&M University, College Station, Texas 77843-2117, USA
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



More information about the Comp.lang.c mailing list