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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.