From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 Date: Thu, 8 Sep 2011 21:41:05 +1200 Message-ID: From: Winston Kodogo To: 9fans@9fans.net Content-Type: text/plain; charset=ISO-8859-1 Subject: [9fans] C question - completely OT, but I'd like to know the answer Topicbox-Message-UUID: 1ba8bf10-ead7-11e9-9d60-3106f5b1d025 Sorry to bother the list, but I thought I might get a sensible answer here from the few remaining people in the world who actually understand C. The following bit of code seems to be more or less syntactically OK: switch (nurdge) { int nigel = 1; case 0: if(nigel == 1) printf("nigel is one.\n"); else printf("nigel is not one.\n"); default: printf("The value of nigel is %d", nigel); } Something close to this compiles under my C compiler, and yet the variable "nigel" is not initialised, and the test inside the first case test is pretty much certain to print "nigel is not one". Although my C++ compiler does complain about an uninitialised variable. I'm puzzled as to why the line "int nigel = 1;" is syntactically OK, and although it seems to have declared the variable "nigel" - else the following code would fail to compile - has failed to give it the initial value of 1, as requested.