LinuxSA Mailing list archives

Index: [thread] [date] [subject] [author] [stats]
  From: Toby Corkindale <tjcorkin@sa.pracom.com.au>
  To  : Jake Hawkes <jakehawkes2001@yahoo.com>
  Date: Thu, 29 Nov 2001 01:02:11 +1030 (CST)

Re: strange C code

What's so wierd about it?
the void main(void) is technically illegal -- you should always define main
as int main and return a value.

the switch(1) will only ever execute case 1, but that's not particularly
odd. Are you sure you didn't mean to ask what would happen if the switch()
was a switch(3) or something?
(ie. what happens if the default: case falls thru?)

Toby



On Wed, 28 Nov 2001, Jake Hawkes wrote:

>
>
> 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
>
>

-- 
 Toby Corkindale
 UNIX Developer, Core Tech R&D
 Technology SA, Pracom Ltd
 288 Glen Osmond Road
 Fullarton,	5063
 South Australia
 Tel: +61 8 8202 9075
 Fax: +61 8 8202 9001
 mailto:Toby.Corkindale@sa.pracom.com.au
 http://www.sa.pracom.com.au/

                  PRIVILEGED - PRIVATE AND CONFIDENTIAL

   Privileged/Confidential Information may be contained in this message.
   If you are not the addressee indicated in this message, you may not
   copy or deliver this message to anyone.  In such case, you should
   destroy this message and notify the sender by reply email. Opinions,
   conclusions and other information in this message that do not relate
   to the official business of this organisation shall be understood as
   neither given nor endorsed by it.

-- 
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