简体   繁体   中英

Initialization of function static variables

I have one static variable declared inside a function, which is not initialized to zero explicitly.

Are all uninitialized static variables inside functions set to zero by default, just as static variables at the global (file) level are?

All static variables without an explicit initializer are initialized to zero.

All the variables going into the BSS segment are initialized to zero.

In C, all global and static variables without an explicit initializer go into the BSS segment and hence are zero by default.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM