Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!ut-sally!husc6!bloom-beacon!oberon!sdcrdcf!trwrb!aero!venera.isi.edu!lmiller From: lmiller@venera.isi.edu (Larry Miller) Newsgroups: comp.lang.c Subject: Re: weird c code/ c test Message-ID: <3345@venera.isi.edu> Date: Tue, 4-Aug-87 12:37:25 EDT Article-I.D.: venera.3345 Posted: Tue Aug 4 12:37:25 1987 Date-Received: Sat, 8-Aug-87 10:42:57 EDT References: <1089@gilsys.UUCP> <3640001@hpindda.HP.COM> Reply-To: lmiller@venera.isi.edu.UUCP (Larry Miller) Organization: Information Sciences Institute, Univ. of So. California Lines: 29 In article <3640001@hpindda.HP.COM> ptc@hpindda.HP.COM (Paul Congdon) writes: >/ 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; /* Note this line is incorrect. It should be: char ***cpp = cp; i.e., one less * */ > >main() >{ > printf("%s", **++cpp); > printf("%s ", *--*++cpp+3); > printf("%s", *cpp[-2]+3); > printf("%s\n", cpp[-1][-1]+1); >} With this correction, the program compiles and runs correctly, indeed producing rather humorous output.