Path: utzoo!attcan!uunet!peregrine!elroy!ames!mailrus!cornell!batcomputer!itsgw!imagine!rpics!kyriazis From: kyriazis@rpics (George Kyriazis) Newsgroups: comp.lang.c Subject: Re: What does Z["ack"] = 5 mean? Keywords: Obfuscated C, wierd Message-ID: <1326@imagine.PAWL.RPI.EDU> Date: 5 Oct 88 20:54:02 GMT References: <14999@agate.BERKELEY.EDU> Sender: news@imagine.PAWL.RPI.EDU Reply-To: kyriazis@turing.cs.rpi.edu (George Kyriazis) Organization: RPI CS Dept. Lines: 25 In article <14999@agate.BERKELEY.EDU> laba-3aw@web.berkeley.edu (Sam Shen) writes: >Exactly what does this mean: > >main() >{ > char Z; > > Z["ack!"] = 5; >} > Something like that was posted a few months ago. Remember that a[b] == *(a+b) [pointer erithmetic] *(a+b) == *(b+a) [obvious] *(b+a) == b[a] [!!!!] In other words Z["ack!"] == "ack!"[Z] (!!). Z happens to be '\0', so what is does is changes the first character of the constant "ack!" to 5. In some systems you can't do that because constants are read-only. I just tried it on a SUN4 and it didn't complain at all.. George Kyriazis kyriazis@turing.cs.rpi.edu ------------------------------