0

my professor taught void main() but in various platform online I saw it as main(void) so what is the difference as it creates a lot of confusion and what is the meaning and why we use it?

  • 1
    Does this answer your question? [What are the valid signatures for C's main() function?](https://stackoverflow.com/questions/2108192/what-are-the-valid-signatures-for-cs-main-function). Also [int main() vs void main() in C](https://stackoverflow.com/q/9356510/364696). And a dozen other duplicates... – ShadowRanger Dec 06 '20 at 16:46
  • There are some differences, but both are wrong – klutt Dec 06 '20 at 16:58
  • Your professor has done you a disservice. `void main()` is not among the signatures for `main` defined by the language standard, and it should not be used unless, possibly, with a C implementation that expressly accepts it an an extension. Nor is it allowed to omit the return type from a function declaration since C99. As a first approximation, `main()` should always be explicitly declared to return `int`. – John Bollinger Dec 06 '20 at 16:59

0 Answers0