+ 2
Must every code have an int main. And why?
2 Respuestas
0
HI,
The return is normally used by the OS to know what the reason your application end, if you want to inform the application that calls your app OR just return a value to the OS to inform any problem occurred during the execution you can do that by the main return.
By default OS uses return 0 for normal END (without error) but you can define your main as VOID MAIN, this means that will be not return anything.
BR,
0
Yes, every program must have a 'main' function. When the program starts, that function is what is called first: it's the starting point of your program.
The 'main' function doesn't have to return an integer though, but that is the convention. Typically that integer represents an error code: different values represent different errors. The 'return 0;' at the end of your 'main' function means that no errors occurred, since you successfully reached the end of your program.