Current location - Quotes Website - Personality signature - In C, a function has no return value, but there are return 1 and return 0 in the function. What does that mean?
In C, a function has no return value, but there are return 1 and return 0 in the function. What does that mean?

For functions with no return value (void), the retrun statement is used to directly terminate the function and return to the upper layer.

In addition, using a return statement with a value in a function declared as void is equivalent to modifying the type of the function by default. This does not seem to be a version of C rules, but both VC and TC do this for this syntax. explanation.

For example, if return 1 appears in a void fun(), the function signature should actually be int fun(), and if return 1.0 appears, it will be double fun()

Many books? ...I have the impression that in some older textbooks, a large number of return1, 0 methods are used to represent function execution results. In fact, they serve as pseudo-boolean values. Today's books and more formal textbooks rarely use this method. Return method without relevant declaration.

Generally speaking, in this type of example: return 1 means "the function ended normally"

return 0 means "the function terminated abnormally, and system state consistency is not guaranteed"