Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!skat.usc.edu!burzin From: burzin@skat.usc.edu (Burzin N. Engineer) Newsgroups: comp.lang.c Subject: Explanation, someone?? Summary: C quiz Message-ID: <33641@usc.edu> Date: 15 Jun 91 12:04:27 GMT Sender: news@usc.edu Organization: University Computing Services--U.S.C. Lines: 56 Nntp-Posting-Host: skat.usc.edu 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@usc.edu University of Southern California UUCP: ..uunet!usc!burzin