rad@genco.bungi.com (Bob Daniel) (12/19/90)
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");
}
bitting-douglas@cs.yale.edu (Douglas Bitting) (12/19/90)
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 \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\