What the funK “return 0” is on main() function in C/C++!

Ridwanul Alam
Aug 10, 2022

--

What is return 0 in C/C++

In the C/C++ program, If the main() function completes all its commands step by step without any error then at the end it will reach the return 0; If it goes till return 0, the compiler takes it as successful execution. Making a main() function with returning 0 is an ideal practice.

If we declare a main() function like this :

void main(){
// all activities to execute
}

then we don’t need to return anything. But this is not a good practice, cause the compiler can’t trace the flawless execution in this way. You may use void main() if you are too much confident about error/exception handling. But in some cases might face issues, some compilers don't support void main();

--

--

Ridwanul Alam
Ridwanul Alam

Written by Ridwanul Alam

A Frontend Web Developer. Devoted to solving new problems and developing interactive web application