Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!brutus.cs.uiuc.edu!psuvax1!psuvax1!flee From: flee@shire.cs.psu.edu (Felix Lee) Newsgroups: comp.lang.c Subject: A perverse switch statement. Message-ID: Date: 13 Oct 89 14:55:10 GMT References: <561@crdos1.crd.ge.COM> <10041@xanth.cs.odu.edu> <10888@riks.csl.sony.co.jp> <1079@m3.mfci.UUCP> Sender: news@psuvax1.cs.psu.edu Organization: Penn State University Computer Science Lines: 22 Something sparked by comp.std.c's "declarations in switches" discussion. Duff's device and Obfuscated C: all perverse. main() { int i, j = 1; for (i = 0; i <= 6; ++i) switch (i) top: case 6: { int k = 3; case 0: for (; ++k % 3; ++j) { case 1: printf(" j = %d,", j); case 2: printf(" k = %d\n", k); } case 3: printf("i = %d\n", i); break; case 4: printf("i = %d\n", i); case 5: goto top; } } -- Felix Lee flee@shire.cs.psu.edu *!psuvax1!flee