bates@bison.DEC (Ken Bates DTN 522-2039) (09/27/85)
As part of release 2.1 of Megamax C, the terminal output was changed from unbuffered to buffered. As a result of this, lines printed to stdio will NOT be printed until receipt of a \n character. For example, consider the following program (delving into your memory): #include <stdio.h> main() { printf("hello, world"); /* Note no trailing '\n' */ } When executed, the usual stdio window will NOT appear, and NO output will be generated. This is due to the fact that the output is buffered, and the implicit exit() at the end of the program will NOT flush the buffer. The only recourse is to include a fflush(stdio), hardly an elegant solution. If this form of IO is used throughout the program, the requirement for the fflush on every operation becomes (in my opinion) very painful. A solution to this problem is to modify the program to force stdio to use unbuffered output: #include <stdio.h> main() { _iob[1]._flag &= ~_LINBUF; /* Clear buffered mode */ _iob[1]._flag |= _UNBUF; /* Set unbuffered mode */ printf("hello, world"); } This time, all works well. The program itself may run a little slower due to the unbuffered IO, but personally, I would rather have a slow program which does what I tell it than a fast program which doesn't! For details (and other flags), take a look at stdio.h on the distribution. -- Ken Bates uucp : decwrl!dec-rhea!dec-bison!bates arpa : bates%bison.dec@decwrl cis : 70047,1226 enet : BISON::BATES phone: (303) 594-2039 mail : Digital Equipment Corp. 301 Rockrimmon Blvd. Colorado Springs, CO 80919