In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
The common way to define a function is as follows:
Function value type function name (mode parameter list) {
Function body
}
1) the function value type, which is the type to which the function goes to the value. In our later programs, there will be many functions with the device return x, which is the type of the function itself. There is also a situation, that is, this function only performs the operation, does not need to go to any value, then at this time its type is the empty type void, this void can be omitted, but once omitted, Keil software will report a warning, so we do not save on weekdays.
2) function names can be made up of arbitrary letters, numbers and underscores, but numbers cannot be used as a sweep. The function name cannot be the same as other functions or variables, nor can it be the crux of the problem. What is the crux of the word? later, we gradually come into contact with, for example, char, which is mostly the crux of the word, a marker with a special function in our program, and this kind of device is named as a function.
3) the mode parameter list, also known as the formal parameter list, is used to transfer data to each other when the function is misappropriated. Some functions, we do not need to pass parameters to it, then we can use void instead, void can be omitted, but whose parentheses can not be omitted.
4) the function body, including the declaration statement part and the execution statement part. The local declaration statement is mainly used to declare the variables used outside the function, and the local performance statement is mainly the statement that some functions need to perform. Pay special attention to the fact that all declaration statements must be placed before the execution statement, otherwise an error will be reported at the time of compilation.
5) A project file must have and only one main function, and most of the time when the program is executed, it starts from the main function.
6) with regard to the concept of formal parameters and actual parameters, we will summarize later. If there is something in the program, everyone will copy it for a period of time. Use it first and explain it later, which is more conducive to understanding.
Let's go back and forth to look at the main function in the shining LED program of last lesson, and everyone will analyze it carefully according to the text, whether the view of the function is much clearer.
Void main () {/ / void is the function type / / the following is the declaration statement local unsigned int i = 0; / / define an unsigned integer variable I, and assign the initial value 0 / / below as the fulfillment statement local ENLED = 0; / / U3, U4 two 74HC138 total enable ADDR3 = 1; / enable U3 to make the normal input ADDR2 = 1; / / turn on the transistor Q16 ADDR1 = 1; ADDR0 = 0; while (1) {LED = 0 by the Y6 input of U3 / / turn on the small lamp for (iTun0; I)
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.