+ 8
Why can't I use void main in c++
12 Respuestas
+ 13
This is because the C++ standard requires main() to return int.
As you probably know, the return value from the main() function is used by the runtime library as the exit code for the process. Both Unix and Win32 support the concept of a (small) integer returned from a process after it has finished. Returning a value from main() provides one way for the programmer to specify this value.
If the code runs with no error then 0 is returned by the main()
+ 7
It has to do with the state of the compiler after the execution.
0 means normal termination while 1 means abnormal termination.
Since the compiler needs to know the status of the code it uses the returned 0 or 1, which are of type int.
It can return 1 as well, btw, AJ || ANANT || AC || ANANY || AY
+ 6
Because in C++ main method always return 0. That's why. It's predefined.
Edited:
In c++ main method either return 0 or 1.
+ 5
AJ || ANANT || AC || ANANY || AY Main function in C++ does not always return 0.
+ 4
Seb TheS & Prometheus [EXAMS]🇸🇬 Thanks
+ 4
Hajji_firas Abnormal termination is just a big word for "I don't think the code is working fine..."
Normal termination is like "Everything is under control, even if something goes wrong"
+ 2
What is the difference bitween abnormal and normal code do you have an example for both
+ 1
You can use void main in different compiler like turbo, dev etc. But you have to use getch with it conio header file.
+ 1
Good
0
Can you give me a example of call by volue now
0
Ashu Singh Baghel Don't ask here. Ask in seperate thread so people can give answer.
- 1
Hii