+ 8

Why can't I use void main in c++

18th Oct 2019, 7:21 AM
Hajji_firas
Hajji_firas - avatar
13 Respostas
+ 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()
18th Oct 2019, 10:30 AM
Arsenic
Arsenic - avatar
+ 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
18th Oct 2019, 7:37 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 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.
18th Oct 2019, 7:25 AM
A͢J
A͢J - avatar
+ 5
AJ || ANANT || AC || ANANY || AY Main function in C++ does not always return 0.
18th Oct 2019, 7:35 AM
Seb TheS
Seb TheS - avatar
18th Oct 2019, 7:51 AM
A͢J
A͢J - avatar
+ 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"
18th Oct 2019, 8:02 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
What is the difference bitween abnormal and normal code do you have an example for both
18th Oct 2019, 7:59 AM
Hajji_firas
Hajji_firas - avatar
+ 1
You can use void main in different compiler like turbo, dev etc. But you have to use getch with it conio header file.
19th Oct 2019, 5:29 PM
Pushpendra Singh
Pushpendra Singh - avatar
+ 1
Good
20th Oct 2019, 3:19 AM
Vijay
Vijay - avatar
0
Can you give me a example of call by volue now
20th Oct 2019, 5:00 AM
Ashu Singh Baghel
Ashu Singh Baghel - avatar
0
Ashu Singh Baghel Don't ask here. Ask in seperate thread so people can give answer.
20th Oct 2019, 6:30 AM
A͢J
A͢J - avatar
- 1
Hii
20th Oct 2019, 4:59 AM
Ashu Singh Baghel
Ashu Singh Baghel - avatar