Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!seismo!ut-sally!utah-cs!utah-gr!pwa-b!philabs!micomvax!musocs!mcgill-vision!mouse From: mouse@mcgill-vision.UUCP Newsgroups: comp.lang.c,misc.jobs.misc Subject: Re: weird c code/ c test Message-ID: <858@mcgill-vision.UUCP> Date: Sat, 8-Aug-87 04:24:21 EDT Article-I.D.: mcgill-v.858 Posted: Sat Aug 8 04:24:21 1987 Date-Received: Tue, 18-Aug-87 02:00:51 EDT References: <1089@gilsys.UUCP> Organization: McGill University, Montreal Lines: 35 Keywords: test, employment, weird, code, pointers Xref: utgpu comp.lang.c:3523 misc.jobs.misc:384 In article <1089@gilsys.UUCP>, mc68020@gilsys.UUCP (Thomas J Keller) writes: [ headhunter who popped a C test, last question of which asks what the output of this program is: ] > #include > char *c[] = { "ENTER", "NEW", "POINT", "FIRST", }; > char **cp[] = { c+3, c+2, c+1, c }; > char ***cpp = cp; [in mc68020's posting, this was "char ****cpp"; presumably *** is right] > 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? What do I think? I think the headhunter has read the C Puzzle Book and decided it'd be a good test for aspiring C programmers to lift a few questions. (I can't be certain, because I read the book a long time ago, but the strings of the c array sound familiar, and the output matches.) I think it is not a particularly relevant question. All it tests is your ability to follow instructions by rote, since I doubt anyone would do this except by keeping track of all the pointers the way the machine would. If I were hiring a C programmer, I doubt I would want this sort of robot. Nor, were I job-hunting, would I want to work to work for someone who wanted such a robot. der Mouse (mouse@mcgill-vision.uucp)