Explanation, someone??
Burzin N. Engineer
burzin at skat.usc.edu
Sat Jun 15 22:04:27 AEST 1991
Hi,
I just gave an interview which had a C quiz and there was this program
that really confused me. I have compiled the program and can still not figure
out what is going on. Any reference or help will be appreciated.
---
char *c[] = {
"ENTER",
"NEW",
"POINT",
"FIRST"
};
char **cp[] = { c+3, c+2, c+1, c};
char ***cpp = cp;
main()
{
printf("%s", *++cpp);
printf("%s", *--*++cpp+3);
printf("%s", *cpp[-2]+3);
printf("%s\n", cpp[-1][-1]+1 );
}
When run it produces:
ERSTEW
=========================================
Another one is :
char input[] = "SSSWILTECH1\1\11W\1WALLMP1";
main()
{
int i, c ;
for (i=2; (c=input[i]) != '\0'; i++){
switch(c) {
case 'a': putchar('i'); continue;
case '1': break;
case 1: while((c = input[++i]) != '\1' && c!='0' );
case 9: putchar('S');
case 'E':
case 'L': continue;
default: putchar(c);
continue;
}
putchar(' ');
}
putchar('\n');
}
which produces:
SWITCH SWAMP
...and to think I thought I knew C.
I would sincerely appreciate some explanation. Thank You.
--
===============================================================================
Burzin N. Engineer Tel. No.Offc: (213) 740 2827 | Home (213) 640 8566
University Computing Services ARPA: burzin at usc.edu
University of Southern California UUCP: ..uunet!usc!burzin
More information about the Comp.lang.c
mailing list