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 > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article shows you how to analyze static keywords, which is concise and easy to understand, which will definitely brighten your eyes. I hope you can gain something through the detailed introduction of this article.
As a keyword in C language, static was introduced to solve the problem that the value of local variables can still be saved after the end of the function. Then in the expansion of C language, another function is added to modify the visibility of functions or variables as this file. From this we can know that the static keyword has two functions in C language: one is to modify variables, and the other is to modify functions.
One: static modifies variables
Variables are divided into local variables (variables defined in the function body) and global variables (variables defined outside the function). Regardless of whether they modify local variables or global variables, the memory space allocated for variables is in the static area.
(1) static global variables:
Works in files that are limited to the definition of a variable, and other files cannot use this variable even if they use the extern declaration. This static global variable can be used by the code from the definition of the variable to the end of the file. The variable cannot be accessed by code before it is defined or by code in other files.
(2) static local variables:
Because the scope of the local variable itself is limited to the function body, there is no debate about whether to use it in other files. The static modification here makes the local variable have some properties of the global variable. When the function is executed for the first time, the static local variable is initialized, and after the function is executed, the static local variable is not destroyed, but continues to exist in memory. In future function execution, the initialization statement of this variable will not be executed again, but its assignment statement will be executed every time, and after the function is executed, the value of the variable will be updated in memory and will not be destroyed.
Two: static modification function
Makes the access property of the function only accessible in this file. Because C language has a long history, in the process of development, we do not want to add other keywords, so we use the keyword static to give this new grammatical features and meaning.
The above content is how to analyze the static keyword. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
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.