LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-29-2004, 03:36 AM   #1
ypzhuang
LQ Newbie
 
Registered: Jul 2004
Location: Shanghai,China
Posts: 7

Rep: Reputation: 0
How many prototype of function main in c?


How many prototype of function main in c?And arguments means what??Thanks!!!
 
Old 07-29-2004, 03:54 AM   #2
barisdemiray
Member
 
Registered: Sep 2003
Location: Ankara/Turkey
Distribution: Slackware
Posts: 155

Rep: Reputation: 30
Take a look at the thread 'main() confusioning in C'
http://www.linuxquestions.org/questi...hreadid=209979
 
Old 12-11-2008, 08:18 PM   #3
sandeep_raju123
LQ Newbie
 
Registered: Dec 2008
Location: Bangalore,India
Posts: 10

Rep: Reputation: 0
sandeep

there are only two prototypes of main, one without arguments and the other without arguments. The arguments are generally argc and *argv[].The argc signifies number of arguments whereas *argv[] represents the actual arguments. These are send while executing along with ./a.out
 
Old 12-11-2008, 08:37 PM   #4
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
Quote:
Originally Posted by sandeep_raju123 View Post
there are only two prototypes of main, one without arguments and the other without arguments. The arguments are generally argc and *argv[].The argc signifies number of arguments whereas *argv[] represents the actual arguments. These are send while executing along with ./a.out
Look at the thread date before writing a reply.
 
Old 12-11-2008, 08:42 PM   #5
sandeep_raju123
LQ Newbie
 
Registered: Dec 2008
Location: Bangalore,India
Posts: 10

Rep: Reputation: 0
Post see this

the main has only two prototypes:

int main (void);
int main (int argc, char ** argv);

The argument argc is the number of command-line arguments passed to the program. The argument argv is a pointer to an array of strings, where argv[0] is the name you used to run your program from the command-line, argv[1] the first argument that you passed to your program, argv[2] the second argument, and so on.
 
Old 12-12-2008, 03:32 AM   #6
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
Originally Posted by sandeep_raju123 View Post
the main has only two prototypes:

int main (void);
int main (int argc, char ** argv);
Three:
Code:
int main(void);
int main (int argc, char **argv);
int main (int argc, char **argv, char **env);
 
Old 12-12-2008, 04:52 AM   #7
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
Quote:
Originally Posted by Hko View Post
Three:
Code:
int main(void);
int main (int argc, char **argv);
int main (int argc, char **argv, char **env);
Two
Quote:
5.1.2.2.1 Program startup
main is the only function that may portably be declared either with zero or two arguments. (The number of other functions’ arguments must match exactly between invocation and definition.)
This special case simply recognizes the widespread practice of leaving off the arguments to main when the program does not access the program argument strings. While many implementations support more than two arguments to main, such practice is neither blessed nor
forbidden by the Standard; a program that defines main with three arguments is not strictly conforming (see §J.5.1.)
*****
 
Old 12-12-2008, 08:07 AM   #8
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
[...]such practice is neither blessed nor
forbidden by the Standard;[...]
OK. Let's finish this issue at two-and-a-half. :-)
 
Old 12-12-2008, 08:19 AM   #9
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
Quote:
Originally Posted by Hko View Post
OK. Let's finish this issue at two-and-a-half. :-)
Quote:
a program that defines main with three arguments is not strictly conforming
OK I can stretch to 2.0000000000000000000000000000000000000000001
 
Old 12-13-2008, 07:53 AM   #10
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
eh..........agreed!
:-)
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Override main function in C joeyBig Programming 8 03-19-2018 06:37 AM
what's the kernel's main() function? LordOfer Linux - General 1 04-06-2005 03:02 PM
Array declaration in class or main function??? redhatrosh Programming 4 03-15-2005 02:13 PM
A main can be changed by a function local without passing anything to the function? ananthbv Programming 10 05-04-2004 01:31 PM
in whst file is the main () function for the kernel? wsimmons Programming 2 12-30-2001 12:08 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration