ProgrammingModerateWipro · Capgemini

A function in a.c is declared `static int helper(void) { ... }`. Which statement is true?

  1. A. It is placed in read-only memory and cannot be called through a pointer
  2. B. Its local variables keep their values between calls
  3. C. It can be called from any file that declares extern int helper(void);
  4. D. It can be called only from code in a.c; another file can define its own helper without a clash

Correct answer: D. It can be called only from code in a.c; another file can define its own helper without a clash

On a function, static means internal linkage: the name is private to its translation unit. It says nothing about the function's locals (only static locals persist). Code in a.c can still pass a pointer to it elsewhere; other files just cannot name it.

More C Programming questions

Exams that ask this topic