LearnFrenzy
Sign in Take a free test

C Variables · Variables MCQ · Question 6

What does static do to a global variable in C? Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links