Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use static in C language

Shulou Source: shulou.com Published: 2022-06-03 09:19:40 10月15日 Update

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!

Tags: Variables static functions global local articles language content not much most more knowledge industry information information channels channels references learning help output Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Microsoft vpn Apple Shulou Tech Info