So I was looking over someone elses code, and the main is unusual, no type. its just:

#include <math.h>
main(int argc, char *argv[])

I've come up with 2 theories:
1) It defaults to int?
2) #if/#endif directives somehow negate the need for int? Have no experience with this though, so its a shot in the dark.

So is anything wrong or nothing to worry about?

9 Years
Discussion Span
Last Post by Salem

K thanks for the fast responce.

And when you say OLD C, does that mean there will be compilation problems with gcc, or just that its really old, but theres no problem.


Old C meaning the latest standard will not allow it. If you compile as C89, the implicit int works, but if you compile as C99, it will throw an error. gcc supports both standards, so it depends on your compiler settings.

Votes + Comments
Clean, sweet, and solid!

main(int argc, char *argv[])
can you please explain the above to me and tell me when and how to use.


I think you're just going round bumping loads of threads with essentially the same question as has already been asked (and answered).

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.