LinuxSA Mailing list archives
Index:
[thread]
[date]
[subject]
[author]
[stats]
From: Andrew Halliday <andrew@recalldesign.com>
To : <linuxsa@linuxsa.org.au>
Date: Thu, 29 Nov 2001 10:00:57 +1030
Re: strange C code
Default will never be executed.
If the input is anything other than one, the output will be 2.
This could possibly be an attempt to use the run-through effects of a case
to start or resume a set of statements by omitting the break statement.
The default definition would be better off at the bottom.
Toby was right, this program should return a value...returning void is bad
practice.
Regards, Andrew Halliday
------------------- | andrew@recalldesign.com | direct: +61 8 8217 0563
Recall Design Pty Ltd | www.recalldesign.com | telephone: +61 8 8217 0500
53 Gilbert Street | | fax: +61 8 8217 0555
Adelaide SA 5000 | | mobile: 0421304901
----- Original Message -----
From: "Jake Hawkes" <jakehawkes2001@yahoo.com>
To: <linuxsa@linuxsa.org.au>
Sent: Wednesday, November 28, 2001 11:59 PM
Subject: strange C code
>
>
> I've never seen this before:
>
>
> #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?
>
> --Jake
>
> =====
> ---
> Jacob Hawkes, B. Eng (CSE)
> Programmer / Analyst
> Metso Automation
> jacob.hawkes@metso.com
> jakehawkes2001@yahoo.com (while onsite in Venezuela)
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
> http://geocities.yahoo.com/ps/info1
>
> --
> 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
>
--
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