3 ms·
The comp.lang.c FAQ (which is quite well respected as a good authorative source on C, I think) states: Q: What's the correct declaration of main()? A: There a
by unwind 17y ago
The comp.lang.c FAQ (which is quite well respected as a good authorative source on C, I think) states:
Q: What's the correct declaration of main()?
A: There are two valid declarations:
int main(void)
int main(int argc, char **argv)
Yet, Knuth states:
main()
This feels like Knuth has done a Chuck Norris on C.
- jsharpe 17y agoOnly problem - that ain't C. ;)
- X-Istence 17y agoOh? What language is it? At first glance it looked like C.
- voidpointer 17y agoIt's CWEB (http://www-cs-faculty.stanford.edu/~uno/cweb.html http://www-cs-faculty.stanford.edu/~uno/cweb.html) A language based on C devised by Knuth as a language for "Literate Programming" (http://www.literateprogramming.com/ http://www.literateprogramming.com/)
- jedbrown 17y agoI assume this is what CTANGLE produces, in which case your rebuttal of unwind's point is flawed. http://gist.github.com/319391 http://gist.github.com/319391 However, C99 section 6.9.1 "Function definitions" asserts that int f(void) { /* ... */ } is equivalent to int f() { /* ... */ } Note that this is not true of a function declaration since int f(); means function accepting unspecified arguments.
- niyazpk 17y agoI haven't done any C programming for years, so correct me if I am wrong. IIRC main() is interpreted as int main() by some compilers.
- wheels 17y agoThat's K&R C: http://en.wikipedia.org/wiki/K%26R_C#K.26R_C http://en.wikipedia.org/wiki/K%26R_C#K.26R_C