From: Thomas Dodd <ted@cypress.com>
To: Andrea Arcangeli <andrea@suse.de>, linux-kernel@vger.kernel.org
Subject: Re: 2.2.18 signal.h
Date: Thu, 21 Dec 2000 12:18:56 -0600 [thread overview]
Message-ID: <3A424990.7CDA4A2C@cypress.com> (raw)
In-Reply-To: <20001215195433.G17781@inspiron.random> <Pine.LNX.4.21.0012151752421.3596-100000@duckman.distro.conectiva> <20001215211404.J17781@inspiron.random>
Andrea Arcangeli wrote:
>
> On Fri, Dec 15, 2000 at 05:55:08PM -0200, Rik van Riel wrote:
> > On Fri, 15 Dec 2000, Andrea Arcangeli wrote:
> >
> > > x()
> > > {
> > >
> > > switch (1) {
> > > case 0:
> > > case 1:
> > > case 2:
> > > case 3:
> > > ;
> > > }
> > > }
> > >
> > > Why am I required to put a `;' only in the last case and not in
> > > all the previous ones?
> >
> > That `;' above is NOT in just the last one. In your above
> > example, all the labels will execute the same `;' statement.
> >
> > In fact, the default behaviour of the switch() operation is
> > to fall through to the next defined label and you have to put
> > in an explicit `break;' if you want to prevent `case 0:' from
> > reaching the `;' below the `case 3:'...
>
> Are you kidding me?
Absolutely NOT.
switch (x) {
case 0:
case 1:
printf ("%d\n", x);
break;
case 2:
printf ("%d\n",x*x);
case 3:
printf ("%d\n", x*x*x);
}
if x==0 or 1, prints x (the 0 or one),
if x==2 , it prints 4 and 8 since no break statement exits the switch,
if x==3, it prints only 27,
any othe value of x, and nothing is printed.
Every C compile I have ever used does this.
Sun's C and C++, HP's C, Microsoft's VC++, Borland's C, and all versions
of gcc and g++.
Grab any C programming book, and find the switch statement.
-Thomas
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2000-12-21 18:50 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-12-15 16:29 2.2.18 signal.h Mike Black
2000-12-15 16:56 ` Andrea Arcangeli
2000-12-15 17:07 ` Richard B. Johnson
2000-12-15 17:43 ` Andrea Arcangeli
2000-12-15 17:59 ` Franz Sirl
2000-12-15 18:34 ` Richard B. Johnson
2000-12-15 18:50 ` Alan Cox
2000-12-15 19:06 ` Horst von Brand
2000-12-15 20:15 ` Michael Meissner
2000-12-15 18:54 ` Andrea Arcangeli
2000-12-15 19:18 ` Ulrich Drepper
2000-12-15 19:57 ` Andrea Arcangeli
2000-12-15 20:09 ` Rik van Riel
2000-12-15 20:22 ` Andrea Arcangeli
2000-12-16 7:53 ` Anuradha Ratnaweera
2000-12-16 13:52 ` Andrea Arcangeli
2000-12-19 16:53 ` Michael Meissner
2000-12-15 19:55 ` Rik van Riel
2000-12-15 20:14 ` Andrea Arcangeli
2000-12-21 18:18 ` Thomas Dodd [this message]
2001-01-02 16:55 ` Andrea Arcangeli
2000-12-15 20:31 ` Michael Meissner
2000-12-17 5:27 ` Albert D. Cahalan
-- strict thread matches above, loose matches on Subject: below --
2000-12-15 21:56 Jesse Pollard
2000-12-15 22:22 ` Andrea Arcangeli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3A424990.7CDA4A2C@cypress.com \
--to=ted@cypress.com \
--cc=andrea@suse.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox