An interesting behaviour in printf
Blair P. Houghton
bph at buengc.BU.EDU
Sun Mar 19 14:29:08 AEST 1989
In article <15938 at cup.portal.com> Tim_CDC_Roberts at cup.portal.com writes:
>In <960 at Portia.Stanford.EDU>, joe at hanauma (Joe Dellinger) asks:
>
>> string[0] = '*';
>> string[1] = '\0';
>> printf("%s\n", string[1]);
>
>No, I expect it to print out (null)\n. The '%s' format item expects to
>
>Trivia question: is the '(null)' output of printf standard or widespread?
>I know that Microsoft C does this; do other compilers?
The uVAX/Ultrix C compiler ignores it whole. The only thing the program emits
is the \n. (I checked it by "funkyprint | od -bc". One char out. \012.
More interesting than I expected. Smells broken.)
The Encore/Umax C compiler emits \022 \012. So, like, what's \022? My
ASCII table says it's a "dc2".
--Blair
"Gesundheit."
More information about the Comp.lang.c
mailing list