0
What is the use of âvoid main()â?
Whenever I compile using âvoid mainâ as my entry point the output always error. Why like that? Should I use int main?
5 Answers
0
provide your code
0
#include <stdio.h>
void main()
{
int x = 5;
if (true);
printf(âhelloâ);
}
0
youâre right. I try it many times but the output errors. So I try int main and it run.
0
main() is a function called by OS, and it should return an int to tell status.
return 0; // successful
if returned something else then OS will know something went wrong with the code.
return - 1, 1, 2, - 2 //:-(
I know this that void main() doesnt return anything, so doesnt mean anything for OS, maybe compiler adds it.
I only remember void main () in text book codes to save 1 line from return statement.