Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!gatech!bloom-beacon!husc6!sri-unix!teknowledge-vaxc!mkhaw From: mkhaw@teknowledge-vaxc.ARPA (Michael Khaw) Newsgroups: comp.lang.c,misc.jobs.misc Subject: Re: weird c code/ c test Message-ID: <15179@teknowledge-vaxc.ARPA> Date: Thu, 30-Jul-87 13:14:57 EDT Article-I.D.: teknowle.15179 Posted: Thu Jul 30 13:14:57 1987 Date-Received: Sun, 2-Aug-87 22:06:59 EDT References: <1089@gilsys.UUCP> Reply-To: mkhaw@teknowledge-vaxc.UUCP (Michael Khaw) Organization: Teknowledge, Inc., Palo Alto CA Lines: 36 Keywords: test, employment, weird, code, pointers Xref: mnetor comp.lang.c:3431 misc.jobs.misc:533 In article <1089@gilsys.UUCP> mc68020@gilsys.UUCP (Thomas J Keller) writes: -> -> 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. ... ->#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); ->} ... -> I do question this as a test, however. That is some pretty esoteric ->pointer manipulation there! What do you think? 1) Apparently, you haven't read _The C Puzzle Book_. This example is straight out of the book, from a puzzle titled "Pointers and Arrays 4: Pointer Stew", except for an error (see point 3). 2) I would have said, "this is unmaintainable code and whoever wrote this should be drawn, quartered, boiled in oil, skewered and burned at the stake". Or, "Are you using this example with Alan Feuer's permission?" 3) "cpp" should be declared as: char ***cpp = cp; Mike Khaw -- internet: mkhaw@teknowledge-vaxc.arpa usenet: {hplabs|sun|ucbvax|decwrl|sri-unix}!mkhaw%teknowledge-vaxc.arpa USnail: Teknowledge Inc, 1850 Embarcadero Rd, POB 10119, Palo Alto, CA ch Man