No need to write return 0 in C

In reality, the main() function always returns an integer value therefore there is an int before the main () function

If the main()  function return 0 means success likewise, if it is return(nonzero) means failure

Int main()
{
Statement 1;
Statement2;
Statement3;
Return 0;
}

There have been many textbooks written on C that state that you should always end the main() function with return 0;

With the older version of C if the compiler notices the main() function with int as the return type and doesn’t return a value causes a warning “control reaches end of non-void function”

But, according to the C99 version, it’s OK to end the main() function without returning a value

In short, the C99 standard states that the main() function will automatically return 0; without any error or warning from the compiler

Mohammed Anees

Hey there, welcome to aneescraftsmanship I am Mohammed Anees an independent developer/blogger. I like to share and discuss the craft with others plus the things which I have learned because I believe that through discussion and sharing a new world opens up

Leave a Reply

Your email address will not be published.