开发者

Initialization of function static variables

开发者 https://www.devze.com 2022-12-19 13:55 出处:网络
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 vari

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 (fi开发者_运维问答le) 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号