Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use static to modify local static variables in C language

Shulou Source: shulou.com Published: 2022-06-03 09:15:48 11月15日 Update

This article mainly shows you "how to use static to modify local static variables in c language". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to modify local static variables with static in c language".

1. The scope is limited to the interior of the function. After leaving the function, it is invalid. * * Life cycle * * until the end of the program.

2. Whether it is an ordinary local variable or a static-modified static local variable, the scope is only valid within the function.

Example

# include int func1 () {int x = 5; x variables; printf ("function func1 local variables x =% d\ n", x); return 0;} int func2 () {static int x = 10; x variables; printf ("function func2 static local variables x =% d\ n", x); return 0;} int main () {for (int I = 0 return I)

Tags: Variables parts functions static language content articles functions learning help ordinary effective periodic examples that is easy to understand more organization life knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Linux Xiaomi Apple Redmi