In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
What this article shares with you is about whether functions can be defined but not called. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Wrong, functions can be nested calls but not nested definitions. In C language, all functions are parallel, that is, when defining functions, they are independent of each other, and one function is not subordinate to another function, that is, functions cannot be nested, but they can call each other, but not main functions.
Wrong, functions can be nested calls but not nested definitions.
C language function
A function is a piece of code that can be reused to perform a function independently. It can receive the data passed by the user or not. The functions that receive user data should specify parameters when they are defined, and those that do not receive user data do not need to be specified. According to this point, functions can be divided into parametric functions and non-parametric functions.
The process of encapsulating a code snippet into a function is called a function definition.
Definition of function
If the function does not receive the data passed by the user, it can be defined without parameters. As follows:
DataType functionName () {/ / body}
If the function needs to receive the data passed by the user, it should be defined with parameters. As follows:
DataType functionName (dataType1 param1, dataType2 param2...) {/ / body}
DataType is the return value type, which can be any data type in the C language, such as int, float, char, and so on.
FunctionName is a function name, it is a kind of identifier, naming rules and identifiers are the same. The parentheses () after the function name cannot be reduced.
DataType1 param1, dataType2 param2... It's a list of parameters. A function can have only one parameter, or it can have multiple arguments, which are separated by. Parameters are also variables in nature, and the type and name should be specified when they are defined. Compared with the definition of non-parameter function, the definition of parameter function is only one more parameter list.
Body is the function body, it is the code that the function needs to execute, and it is the main part of the function. Even if there is only one statement, the function body is surrounded by {}.
If there is a return value, use the return statement in the function body to return it. The data from return should be of the same type as dataType.
Return is a keyword in C language, which can only be used in functions to return processing results.
Example:
# include int sum () {int I, sum=0; for (iTun1; I factorial ()
If a function A () calls another function B () during the definition or call, then we call A () the main tone function or the main function, and B () the modulated function.
When the tone function encounters the modulated function, the tone function will be paused and the CPU will execute the code of the modulated function; after the tuned function is finished, it will return to the tone function, and the tone function will continue to execute according to the previous state.
The execution process of a C language program can be thought of as a mutual call process between multiple functions, which form a simple or complex call chain. The chain starts with main () and ends with main (). When main () has called all the functions, it returns a value (for example, return 0;) to end its own life, thus ending the entire program.
A function is a reusable code block, and CPU executes the code one by one next to each other. When a function call is encountered, CPU first records the address of the next code in the current code block (assuming the address is 0X1000), then jumps to another code block, and then comes back to execute the code at 0X1000 after execution. The whole process is equivalent to CPU opening a short distance, temporarily put aside the work in hand to do something else, and then continue the work just now.
Thank you for reading! This is the end of the article on "can functions be nested but not nested?". I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.