Practice mode C Language

What does the file-scope declaration extern int count; do in C?

Correct answer C. It declares count without defining it, so the storage must be defined elsewhere

Explanation

extern without an initialiser is a declaration: it tells the compiler that an int named count exists with external linkage, but it does not allocate storage. Exactly one translation unit must provide the definition, such as int count = 0;, or the linker reports an undefined reference. Making a name private to a file is the job of static, not extern.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.