What does Z["ack"] = 5 mean?
The Beach Bum
jfh at rpp386.Dallas.TX.US
Thu Oct 6 14:27:31 AEST 1988
In article <14999 at agate.BERKELEY.EDU> laba-3aw at web.berkeley.edu (Sam Shen) writes:
>Exactly what does this mean:
>
>main()
>{
> char Z;
>
> Z["ack!"] = 5;
>}
The same as
char Z;
"ack!"[Z] = 5;
>This doesn't look right to me. However, cc doesn't complain
>at all about it. Lint says:
>
>blah.c(5): warning: Z may be used before set
Right. It should be
char Z = 0;
to give Z a reasonable value.
That would produce code to change the 'a' in "ack!" to a \005, which is ^E.
>Worse yet, the executable produced by gcc core dumps. Oh, by the way, this
>is all on a Sun-3/50.
And well it should.
--
John F. Haugh II (jfh at rpp386.Dallas.TX.US) HASA, "S" Division
"Why waste negative entropy on comments, when you could use the same
entropy to create bugs instead?" -- Steve Elias
More information about the Comp.lang.c
mailing list