Originally Posted by
slingerland3g
Here is the deal.
main() must return an int for obvious reasons already explained.
As far as functions being below main(), is, as explained, governed by project coding rules or up to the lead developer. Whats your technique then? There really is no wrong way, but more of how readable is your code and helps to strengthen self documentation.
If you provide function declarations, then the function definitions can be below main().
- By providing function declaration before main(), provides more of an OOP approach of which you can move those function declarations to another header file for easier manageability/code modifications latter.
- Also as the project grows in size or if more than 2 programmers need to compile in changes, then moving your functions to another header file, again, adds to the OOPness of the project.
- If everything must be at the top of main(), then your declares and definitions must be provided as this helps the compiler.(Thats my understanding)