+ 1
Does main function have to have it datatype?
4 odpowiedzi
+ 5
Though it gets compiled and runs but the compiler will warn about the lack of return type. So, yes it's better to be specified otherwise the compiler issues a warning (-Wreturn-type) like
"ISO C++ forbids declaration of 'main' with no type"
And having a warning is something smelly in a source code! 8D
+ 5
"Can it have void return type"
In pre-standard C, yes. But as far as the standard concerns:
In C++
"It shall have a declared return type of type int [...]"
In C
"It shall be defined with a return type of int and with no parameters:
int main(void) { /* ... */ } "
+ 2
Thanks
+ 1
Can it have void return type