Escape sequences for printf() defined by SVID

Doug Gwyn gwyn at smoke.BRL.MIL
Fri Jan 5 12:45:22 AEST 1990


In article <1990Jan3.144808.6319 at sssab.se> sveer at sssab.se (Sven L Eriksson) writes:
>However SVID (Issue 2) states that the format string may contain these
>escape sequences. This implies that it is possible for the actual
>format string printf sees to contain the characters '\' and 'n', and
>still be converted into a newline. This whould be very convenient if
>the format string is received from elsewhere, e.g. stdin.

You're right about the SVID (Issue 3 as well as Issue 2) implying that
the two adjacent character codes '\' and 'n' in the format string are
treated as meaning "output a new-line".  However, that is simply a
mistake in the SVID, which should have called these "control characters"
or better yet have described the control actions separately from the
printf() description.

In fact, such an implementation would run directly counter to the C
Standard (which requires that these "ordinary characters" be output
without interpretation by printf()), and AT&T has indicated that that
was NOT their intent.

Presumably, if you bring this to AT&T's attention it might get fixed
in a future Issue of the SVID.



More information about the Comp.std.c mailing list