Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Integer type extension and switch Date: Tue, 15 Nov 2016 13:54:52 -0800 Organization: None to speak of Lines: 39 Message-ID: References: <326617a3-8f24-4110-8349-db7a0c17e7de@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="de46ff73fe43b8b35b0550d5525951b1"; logging-data="9452"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/1p1FOVpCyQAEyx/VIHLIb" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:M9C8HRKL7BdeyCPyYIpeo0NqiNs= sha1:iCv/M4/HU+sQaDQ2k2vR0bsYyUc= Xref: csiph.com comp.lang.c:96654 janus writes: > Why is the below not printing anything at all? > > #include > int main() > { > int a=10; > switch(a) > { > case '1': > printf("ONE\n"); > break; > case '2': > printf("TWO\n"); > break; > defa1ut: > printf("NONE\n"); > } > return 0; > } I suspect you're already aware that you misspelled the "default" keyword. "defa1ut:" is an ordinary label that could be used as the target of a goto. Strictly speaking there's no guarantee that '1' and '2' have values other than 10, but they don't in any actual implementation I've ever heard of. It would have been more subtle if you'd written "defau1t". An unrelated point: "int main(void)" is more explicit than "int main()" and doesn't rely on an obsolescent feature. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"