+ 2
Where should we use void main() and where should we use int main()??
6 ответов
+ 1
use int main when there's chance of an error. If you're doing something that might produce errors (such as opening files, dereferencing pointers etc.) use int main so that by the return status you can tell if any error occurred or not
0
Use void main() if your function does not output anything and use int main() if your function outputs anything.
0
doesn't matter if you use void main() ..
void means empty... which means function will not return any value...but of you write int main() you have to write return 0;
else you will get an error function should return a value..
0
1. void main() returns null(no return keyword required)
2. int main() requires return value(even if you have not used it in the code, compiler automatically adds it)
the return value is 0 for success and non-zero for errors
.Hope this helps.
0
depends on the version you use. If you are using a newer version like the dev C++, keep using int main(). manuals say that it returns a value to OS. Not sure what that does, but programs don't run in dev c++ without int main in dev c++
0
Can you guys give me an example? Is It like : int main wait(300);?