Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!ames!ptsfa!nonvon!gilsys!mc68020 From: mc68020@gilsys.UUCP (Thomas J Keller) Newsgroups: comp.lang.c,misc.jobs.misc Subject: weird c code/ c test Message-ID: <1089@gilsys.UUCP> Date: Wed, 29-Jul-87 02:17:48 EDT Article-I.D.: gilsys.1089 Posted: Wed Jul 29 02:17:48 1987 Date-Received: Sat, 1-Aug-87 02:44:04 EDT Organization: Consequently Computers, Santa Rosa, Ca Lines: 40 Keywords: test, employment, weird, code, pointers Xref: mnetor comp.lang.c:3370 misc.jobs.misc:513 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