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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
07-29-2004, 04:36 AM
|
#1
|
LQ Newbie
Registered: Jul 2004
Location: Shanghai,China
Posts: 7
Rep:
|
How many prototype of function main in c?
How many prototype of function main in c?And arguments means what??Thanks!!!
|
|
|
12-11-2008, 09:18 PM
|
#3
|
LQ Newbie
Registered: Dec 2008
Location: Bangalore,India
Posts: 10
Rep:
|
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
|
|
|
12-11-2008, 09:37 PM
|
#4
|
Senior Member
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Rep:
|
Quote:
Originally Posted by sandeep_raju123
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.
|
|
|
12-11-2008, 09:42 PM
|
#5
|
LQ Newbie
Registered: Dec 2008
Location: Bangalore,India
Posts: 10
Rep:
|
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.
|
|
|
12-12-2008, 04:32 AM
|
#6
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536
Rep:
|
Quote:
Originally Posted by sandeep_raju123
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);
|
|
|
12-12-2008, 05:52 AM
|
#7
|
Member
Registered: Oct 2005
Posts: 970
Rep:
|
Quote:
Originally Posted by Hko
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.)
|
*****
|
|
|
12-12-2008, 09:07 AM
|
#8
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536
Rep:
|
Quote:
[...]such practice is neither blessed nor
forbidden by the Standard;[...]
|
OK. Let's finish this issue at two-and-a-half. :-)
|
|
|
12-12-2008, 09:19 AM
|
#9
|
Member
Registered: Oct 2005
Posts: 970
Rep:
|
Quote:
Originally Posted by Hko
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
|
|
|
12-13-2008, 08:53 AM
|
#10
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536
Rep:
|
eh..........agreed!
:-)
|
|
|
All times are GMT -5. The time now is 02:58 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|