Sherm Pendley said:
Yes, it's legal... What makes you think it might not be?
That would have been clearer if Chad had put his entire question
in the body of the message rather than having part of it only in
the subject.
I think Chad is concerned that the lack of a "\n" in the printf
might cause it to be illegal.
It's implementation-defined whether the last line of a text stream
requires a terminating new-line (C99 7.19.2p2). This just means
that a '\n' should be the last character written to stdout before
the end of the program; there's no requirement for each printf call
to write a new-line. It's perfectly valid to build up an output
line with multiple calls to printf:
printf("Hello");
printf(", world");
printf("\n");
Note that the Standard doesn't use the terms "legal" and "illegal"
(apart from one reference to "illegal instruction" in a footnote).
A program that writes to stdout and fails to write a terminating
new-line:
#include <stdio.h>
int main(void) {
printf("Missing newline");
return 0;
}
is not "illegal". If it's executed on an implementation that
*doesn't* require a terminating new-line, the standard doesn't
actually say what happens, but there's certainly no requirement
for the system to diagnose any problem. I believe the behavior
is undefined. (For example, the string "Missing newline" might
never appear.)