An interesting behaviour in printf

Barry Margolin barmar at think.COM
Mon Mar 20 10:23:10 AEST 1989


In article <2343 at buengc.BU.EDU> bph at buengc.bu.edu (Blair P. Houghton) writes:
>>In <960 at Portia.Stanford.EDU>, joe at hanauma (Joe Dellinger) asks:
>>>	string[0] = '*';
>>>	string[1] = '\0';
>>>	printf("%s\n", string[1]);
>The Encore/Umax C compiler emits \022 \012.  So, like, what's \022?  My
>ASCII table says it's a "dc2".

In this case, the fact that it's DC2 is immaterial.  You passed a
pointer to location 0 to printf, so it printed the string that
happened to be at location 0 in memory, which appears to be
\022<Space>.

Barry Margolin
Thinking Machines Corp.

barmar at think.com
{uunet,harvard}!think!barmar



More information about the Comp.lang.c mailing list