Question 6
Back to Exercise
What is the effect of static on a variable defined at file scope?
- A It keeps its value between function calls
- B It gives the variable internal linkage: other source files cannot access it Correct
- C It makes it read-only
- D It moves it to the stack
Correct Answer: Option B
At file scope, every variable already lives for the whole program. static there changes only linkage: the name is private to its translation unit, which avoids clashes with other files.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!