LinuxSA Mailing list archives
Index:
[thread]
[date]
[subject]
[author]
[stats]
From: Michael Wardle <michael.wardle@adacel.com>
To : Jake Hawkes <jakehawkes2001@yahoo.com>
<linuxsa@linuxsa.org.au>
Date: Thu, 29 Nov 2001 10:41:06 +1100
Re: strange C code
----- Original Message -----
From: "Jake Hawkes" <jakehawkes2001@yahoo.com>
To: <linuxsa@linuxsa.org.au>
Sent: Thursday, November 29, 2001 12:29 AM
Subject: strange C code
> #include <stdio.h>
>
> void main(void)
> {
> switch(1)
> {
> default:
> printf("default");
> case 2:
> printf("2\n");
> break;
> case 1:
> printf("1\n");
> break;
> }
> }
>
>
> waddaya reckon the output would be?
I think the thing of interest here is supposed to be the inclusion of
the "default" case at the first case, whereas it is traditionally listed
last. C seems to do the logical thing here and do case 1, but other
languages (such as Ada) may have different results for equivalent code.
--
MICHAEL WARDLE
Adacel Technologies
--
LinuxSA WWW: http://www.linuxsa.org.au/ IRC: #linuxsa on irc.linux.org.au
To unsubscribe from the LinuxSA list:
mail linuxsa-request@linuxsa.org.au with "unsubscribe" as the subject
Index:
[thread]
[date]
[subject]
[author]
[stats]
Return to the LinuxSA Mailing List Information Page