How do I write a C++ factorial calculator with a for loop?

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
30 replies · 8K views
estro said:
You main function looks like this: int main (void), it means that your function must return an integer. [you can change it to void main (void), then you will not need any return...]


Actually, main implicitly returns 0 for C++, so (for the main function only) you may omit "return 0;"

void main(void) is not okay!

It is not what is specified by the standards.

The caller is expecting a return value, and that value should be 0 for success.

It could result in stack corruption.
 
Last edited: