N
nroberts
In the faq for this group:
Q: What's the correct declaration of main()?
A: There are two valid declarations:
int main(void)
int main(int argc, char **argv)
although they can be written in a variety of ways. The second parameter
may be declared char *argv[] (see question 6.4), you can use any names
for the two parameters, and you can use old-style syntax:
int main()
int main(argc, argv)
int argc; char **argv;
.......... http://c-faq.com/ansi/maindecl.html
The way this is worded it makes one think that "int main()" is a valid
declaration of main. However, main is allowed to only take two params
of (int, char **) or 0, correct? In C is not an empty param list an
"unspecified" param list? In that case "int main()" would be invalid
as it matches neither of the standard signatures.
Another faq claiming to represent this group has the following text for
the same Q:
A: Either int main(), int main(void), or int main(int argc,
char *argv[]) (with alternate spellings of argc and *argv[]
obviously allowed). See also questions 11.12b to 11.15 below.
References: ISO Sec. 5.1.2.2.1, Sec. G.5.1; H&S Sec. 20.1 p.
416; CT&P Sec. 3.10 pp. 50-51.
............... http://www.faqs.org/faqs/C-faq/faq/
It also has "int main()" but has no reasoning for its validity except
ref to the std I don't have access to. Is that truely a valid
signature? I always thought you _needed_ (void).
Q: What's the correct declaration of main()?
A: There are two valid declarations:
int main(void)
int main(int argc, char **argv)
although they can be written in a variety of ways. The second parameter
may be declared char *argv[] (see question 6.4), you can use any names
for the two parameters, and you can use old-style syntax:
int main()
int main(argc, argv)
int argc; char **argv;
.......... http://c-faq.com/ansi/maindecl.html
The way this is worded it makes one think that "int main()" is a valid
declaration of main. However, main is allowed to only take two params
of (int, char **) or 0, correct? In C is not an empty param list an
"unspecified" param list? In that case "int main()" would be invalid
as it matches neither of the standard signatures.
Another faq claiming to represent this group has the following text for
the same Q:
A: Either int main(), int main(void), or int main(int argc,
char *argv[]) (with alternate spellings of argc and *argv[]
obviously allowed). See also questions 11.12b to 11.15 below.
References: ISO Sec. 5.1.2.2.1, Sec. G.5.1; H&S Sec. 20.1 p.
416; CT&P Sec. 3.10 pp. 50-51.
............... http://www.faqs.org/faqs/C-faq/faq/
It also has "int main()" but has no reasoning for its validity except
ref to the std I don't have access to. Is that truely a valid
signature? I always thought you _needed_ (void).