K
Keith Thompson
Kenneth Brody said:Is an implementation allowed to say that the behavior of leaving off
the terminating newline is dependent on things outside the scope of
the C compiler?
For example, suppose you are sending the output to a printer, which
won't print the last line if it's not newline-terminated, even though
the C implementation guarantees that it will send everything up to
the final non-newline character? However, if going to the screen,
the output will be just fine.
One solution in that case would be to say that the trailing new-line
is required (leaving the behavior undefined if it's missing), and then
go ahead and describe what happens in some cases.
Though if the documentation made a more realistic statement that the
trailing new-line is not required if you're writing to a file, but
leaving it off might have unpredictable consequences if you're writing
to a device, I for one wouldn't complain.