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?

Recommended Answers

All 6 Replies

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.

commented: Clean, sweet, and solid! +18

K thanks.

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).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.