Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!hpda!hpisoa2!hpindda!ptc From: ptc@hpindda.HP.COM (Paul Congdon) Newsgroups: comp.lang.c Subject: Re: weird c code/ c test Message-ID: <3640001@hpindda.HP.COM> Date: Fri, 31-Jul-87 13:48:18 EDT Article-I.D.: hpindda.3640001 Posted: Fri Jul 31 13:48:18 1987 Date-Received: Sun, 2-Aug-87 10:17:08 EDT References: <1089@gilsys.UUCP> Organization: Hewlett Packard, Cupertino Lines: 42 / hpindda:comp.lang.c / mc68020@gilsys.UUCP (Thomas J Keller) / 11:17 pm Jul 28, 1987 / I just had a strange experience today. I went to see a head hunter about an opening she wanted me to consider, and she popped this "C test" on me. Most of it was pretty straight forward, but the last question on the test was a **BITCH**. See if you can determine the output of this program without actually compiling it: #include char *c[] = { "ENTER", "NEW", "POINT", "FIRST" }; char **cp[] = { c+3, c+2, c+1, c }; char ****cpp = cp; main() { printf("%s", **++cpp); printf("%s ", *--*++cpp+3); printf("%s", *cpp[-2]+3); printf("%s\n", cpp[-1][-1]+1); } (actually, the program AS PRESENTED probably wouldn't have compiled, as the *c declaration was as follows: char *c[] = { "ENTER", "NEW", "POINT", "FRIST", }; ) NOTE: as I entered it here, it *DOES* compile, and the output is fairly humorous. I do question this as a test, however. That is some pretty esoteric pointer manipulation there! What do you think? -- Tom : The conservatives always grouse about "Law & Order" when the liberals Keller : break the law...when the Reagan Admin. does it, it's PATRIOTISM! UUCP : {ihnp4,ames,qantel,sun,amdahl,lll-crg,pyramid}!ptsfa!gilsys!mc68020 BITNET : ptsfa!gilsys!mc68020@ames.com ----------