Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Is it possible to have two main functions in a c program?

Reply
Thread Tools

Is it possible to have two main functions in a c program?

 
 
Walter Roberson
Guest
Posts: n/a
 
      04-06-2008
In article <(E-Mail Removed)>,
Robbie Hatley <(E-Mail Removed)> wrote:

>Walter Roberson wrote:


>> Robbie Hatley wrote:


>> > No. Not in C. There must be exactly ONE main, with one of these two
>> > signatures:


>> > int main (void)
>> > int main (int, char**)


>> Citation?


>ISO/IEC 9899:1999 (E) section 5.1.2.2.1 :


>5.1.2.2.1 Program startup


> It shall be defined with a return type of int and with no
> parameters:


> or with two parameters (referred to here as argc and argv,


> or equivalent;9) or in some other implementation-defined manner.


Your posting to which I replied said "There must be exactly ONE main,
with one of these two signatures" You missed that last part "or in some
other implementation-defined manner", which allows for the
possibility of other signatures.


>Now, you can try to violate that by having functions called
>"main" in two different modules


"try"?? I showed source code!

Your amended answer should therefore not have been
"No. You might be able to trick it, but don't do that"; it should
instead have been "Yes, you can trick it -- but don't do that".
--
"Walter is undoubtedly the country's and club's most popular player."
-- vitalfootball.co.uk
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to have two main methods in a java program ? aks_java Java 6 06-10-2009 03:16 PM
Re: Do i have to have a main function? Keith Halligan C++ 3 05-24-2007 09:49 AM
Do i have to have a main function? PencoOdStip@gmail.com C++ 5 05-24-2007 09:45 AM
please help me in distinguish redefining functions, overloading functions and overriding functions. Xiangliang Meng C++ 1 06-21-2004 03:11 AM



Advertisments