What does return mean in c language

青灯夜游
Release: 2020-09-02 14:29:13
Original
45394 people have browsed it

return means "return" in C language. Return means to transfer the program flow from the called function to the calling function and bring the value of the expression back to the calling function to realize the return of the function value. The return can be accompanied by a return value, which is specified by the parameter after return.

What does return mean in c language

Function is the basic component of C language. A C program can be composed of a main function and several subroutine functions. The main function calls other subroutine functions. Other subroutine functions can also call each other. It is usually hoped that the main function can get a certain value through function calls, which is the return value of the function.

In C language, the modular programming idea is realized through functions, that is, functions are used to define the functional modules, and then the program functions are realized through calls between functions. Therefore, the function has a calling function and a called function.

Parameters are the interface for information communication between the calling function and the called function. In the definition and description statement of the function, we call the parameters in parentheses after the function name formal parameters, or "formal parameters" for short. In the calling statement of the calling function, the parameters used in parentheses after the function name are called actual parameters, or "actual parameters" for short.

When the function is called, the actual parameters must pass data to the formal parameters. After the function is called and completes a certain function, some data must also be returned to the calling function.

return means to transfer the program flow from the called function to the calling function and bring the value of the expression back to the calling function to realize the return of the function value. The return can be accompanied by a return value, as shown by return The following parameters are specified.

Return is usually necessary because the calculation result is usually brought out through the return value when the function is called. If the function execution does not need to return calculation results, it is often necessary to return a status code to indicate whether the function is executed smoothly or not (-1 and 0 are the most commonly used status codes). The calling function can judge the execution of the called function through the return value. Condition.

The meaning of return

In a function, if a return statement is encountered, the program will return to the next statement that calls the function, that is to say, jump out of the function of execution, return to the original place and continue execution. But if the return statement is encountered in the main function, the entire program will stop and exit the execution of the program.

The return value of the function is realized by the return statement return. The last operation performed by the function is return. The meaning of return is:

(1) The subroutine function returns to the calling function and declares When an execution of the function ends, the variable unit allocated during the call is revoked;

(2) Send the function value to the calling expression. Of course, this is not necessary because some functions have return values. Some functions have no return value.

return Function 1

means return. This program can be ended without parameters. If your member runs here, you will not run it further. , you can add a return statement and it will not be executed again.

return Function 2

Return the value of the specified type. When defining the function, there is not int af();int. Here is the return value, followed by return. This return value can be assigned to other variables after this function is executed, and its value is the value after return.

For more related knowledge, please visit: PHP Chinese website!

The above is the detailed content of What does return mean in c language. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template