Joke Collection Website - Public benefit messages - Why do some functions in C language need to have return values? What is the return value?

Why do some functions in C language need to have return values? What is the return value?

The return value is for the convenience of calling from the function and returning the value to the calling function.

Because this function can also be realized with the parameter pointer, it can actually be realized that any function has no return value (completely passed by the parameter).

But many times,

The return value is easier to write than the way parameters are returned.

For example, if the return value is used to determine whether the function is executed correctly.

Then you can.

if(func()) ...

Write directly.

If you use parameters, you must write two sentences.

int a;

func(& amp; a);

If (a) ...

Therefore, the return value is not necessary, just for convenience.