How to use static in C language
Editor to share with you how to use static in the c language, I believe most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's learn about it!
1. If a local variable is modified with static, it is a local static variable.
# include int main () {static int x = 0; / / Local static variable printf ("www.codersrc.com"); return 0;}
2. If a global variable is decorated with static, it is a global static variable.
# include static int x = 0; / / Global static variable int main () {printf ("www.codersrc.com"); return 0;}
3. If you modify a function with static, the function is static.
# include static int func () / / static function {printf ("static function"); return 0;} int main () {func (); printf ("www.codersrc.com"); return 0;} / * output: static function www.codersrc.com*/ above is all the content of the article "how to use static in c language". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!