Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Integer type extension and switch |
| Date | 2016-11-15 13:54 -0800 |
| Organization | None to speak of |
| Message-ID | <lna8d0if2r.fsf@kst-u.example.com> (permalink) |
| References | <326617a3-8f24-4110-8349-db7a0c17e7de@googlegroups.com> |
janus <emekamicro@gmail.com> writes:
> Why is the below not printing anything at all?
>
> #include<stdio.h>
> 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 <http://www.ghoti.net/~kst>
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"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Integer type extension and switch janus <emekamicro@gmail.com> - 2016-11-15 13:43 -0800 Re: Integer type extension and switch Richard Heathfield <rjh@cpax.org.uk> - 2016-11-15 21:48 +0000 Re: Integer type extension and switch supercat@casperkitty.com - 2016-11-15 13:49 -0800 Re: Integer type extension and switch Keith Thompson <kst-u@mib.org> - 2016-11-15 13:54 -0800 Re: Integer type extension and switch Ike Naar <ike@iceland.freeshell.org> - 2016-11-16 21:45 +0000 Re: Integer type extension and switch "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-17 22:17 +0800
csiph-web