In C, what value does a static local variable have if it is declared without an initialiser?
Correct answer C. Zero
Explanation
Objects with static storage duration, including static locals and file-scope variables, are initialised before program start-up; if no initialiser is given they are set to zero (null for pointers). Ordinary automatic locals are different: without an initialiser their value is indeterminate, and reading it is a bug. A static local is initialised only once, not on every call.
Answer checked How we write and check questions
Discussion