Home > Software design >  What does returning a value really mean?
What does returning a value really mean?

Time:08-20

return 0 is a convention that it will execute when there is no error and it will return 0. There is also a difference in writing return 0 inside main() func and outside main() func.

But what does it actually mean to return a value?

It might be copy of some question. But I have read all the answers and then only making a new thread.

Geeks for Geeks says:

pic credit geekforgeeks

CodePudding user response:

The August 4, 2022 working draft of the C standard, section 5.1.2.2.3 says:

If the return type of the main function is a type compatible with int, a return from the initial call to the main function is equivalent to calling the exit function with the value returned by the main function as its argument; reaching the } that terminates the main function returns a value of 0. If the return type is not compatible with int, the termination status returned to the host environment is unspecified.

The return value for any other function is user-defined.

  •  Tags:  
  • c
  • Related