Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!yale!cs.yale.edu!bitting-douglas From: bitting-douglas@cs.yale.edu (Douglas Bitting) Newsgroups: comp.sys.mac.programmer Subject: Re: Pointer Mania (a quiz) Message-ID: <27873@cs.yale.edu> Date: 19 Dec 90 09:15:52 GMT References: <13650001@hpspdra.HP.COM> <167@genco.bungi.com> Sender: news@cs.yale.edu Organization: Yale University Computer Science Dept., New Haven, CT 06520-2158 Lines: 39 Nntp-Posting-Host: monkey.zoo.cs.yale.edu Originator: bitting@monkey.CS.Yale.Edu In article <167@genco.bungi.com> rad@genco.bungi.com (Bob Daniel) writes: >I interviewed with a long distance company last week (for C programming) >and was given a small quiz. Give this a try (without compiling it)... > >char *c[]={"ENTER","NEW","POINT","FIRST"}; >char **cp[]={c+3,c+2,c+1,c}; >char ***cpp=cp; > >main() >{ > printf("\n\n%s",**++cpp); > printf("%s ",*--*++cpp+3); > printf("%s",cpp[-2]+3); ^^^^^^^^^ > printf("%s",cpp[-1][-1]+1); > printf("\n"); >} Shouldn't that be *cpp[-2]+3? It seems to me that it doesn't make any sense unless that is how it is called. That is a neat little test... you definitely have to know your operator precedence to get that one right... I stared at it for a few minutes, but I got it... without compiling (well, I did compile, but only to make sure that I got it right... :-) Try it... it is a good exercise. /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ Doug Bitting || Internet: U.S. Snail Mail: || bitting@cs.yale.edu PO Box 3043 Yale Station || "Peace is Joy resting, New Haven, CT || Joy is Peace dancing." 06520 || --source unknown to me ==================================++=================================== "Guts and Chutzpah are not the same. With guts you can charge a machine gun bunker. With Chutzpah, you can do the same, but wearing a mickey mouse hat..." --Mike \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\