Why does errno contain ENOTTY after a call to printf?
Many implementations of the stdio package adjust their behavior slightly if stdout is a terminal. To make the determination, these implementations perform an operation which fails (with ENOTTY) if stdout is not a terminal. Although the output operation goes on to complete successfully, errno still contains ENOTTY. Reference: CT&P Sec. 5.4 p. 73. 11.3: My program’s prompts and intermediate output don’t always show up on the screen, especially when I pipe the output through another program. A: It is best to use an explicit fflush(stdout) whenever output should definitely be visible. Several mechanisms attempt to perform the fflush for you, at the “right time,” but they tend to apply only when stdout is a terminal. (See question 11.2.) 11.4: When I read from the keyboard with scanf, it seems to hang until I type one extra line of input. A: scanf was designed for free-format input, which is seldom what you want when reading from the keyboard. In particular, “\n” in a format string does _no