Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!utcsri!flaps From: flaps@utcsri.UUCP Newsgroups: comp.lang.c,misc.jobs.misc Subject: Re: weird c code/ c test Message-ID: <5192@utcsri.UUCP> Date: Wed, 5-Aug-87 13:34:53 EDT Article-I.D.: utcsri.5192 Posted: Wed Aug 5 13:34:53 1987 Date-Received: Fri, 7-Aug-87 05:31:27 EDT References: <1089@gilsys.UUCP> Reply-To: flaps@utcsri.UUCP (Alan J Rosenthal) Organization: University of Toronto Lines: 54 Keywords: test, employment, weird, code, pointers Xref: utgpu comp.lang.c:3309 misc.jobs.misc:358 Summary: 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 Huh? Not used in the program below. >char *c[] = { "ENTER", "NEW", "POINT", "FIRST" }; [etc] >main() >{ [unbelievable garbage with pointers, prints "POINTER STEW\n"] >} Well, I made a mistake working it out near the end, but I wasn't being very careful. I _did_ get all the precedence right without looking it up, though. But, really this program should be written as: main() { printf("POINTER STEW\n"); } or even better without a program as simply alias echo POINTER STEW Since you mention it, I had an interesting test at a job I applied for just this very morning. They asked what the output from the following program would be: main() { printf("%s\n",0x637F3A0); } You see, at that address in their machines the string "POINTER STEW\n" was invariably stored. Fortunately I had just been reading comp.lang.c so I got it right. Actually, the main problem with this program was that they missed the cast, it should have been "(char *)0x637F3A0". -- // Alan J Rosenthal // \\ // flaps@csri.toronto.edu, {seismo!utai or utzoo}!utcsri!flaps, \// flaps@toronto on csnet, flaps at utorgpu on bitnet. "To be whole is to be part; true voyage is return."