Why am i unable to use void main() in c++ ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Why am i unable to use void main() in c++ ?

The error for using void main is telling that main must return int value can anybody explain what it means ?

20th Mar 2019, 5:51 AM
Shikher Jaitly
Shikher Jaitly - avatar
1 Answer
+ 8
You must return an int value in main() function. It tells the system if the program has successfully run or not. So, if you opt to use void, then it means you are not going to return anything. But the system will still seek for an int value. That is why it raises an error. Therefore, you cannot use void as the data type for the main() function.
20th Mar 2019, 5:58 AM
Letsintegreat
Letsintegreat - avatar