Question 21
What compile-time result occurs when initializing 'static int s = x;' where 'x' is a local auto variable?
Detailed Solution
Variables with static storage duration must be initialized with constant expressions known at compile time.
What compile-time result occurs when initializing 'static int s = x;' where 'x' is a local auto variable?
Variables with static storage duration must be initialized with constant expressions known at compile time.
Which storage class specifier restricts global variable visibility solely to the current translation unit (.c file)?
Declaring a global variable as static grants it internal linkage, hiding it from other translation units.
What is the purpose of the 'extern' keyword in variable declarations?
The 'extern' keyword informs the compiler that the identifier is defined elsewhere with external linkage.
What will happen if you apply the address-of operator (&) to a variable declared with 'register' storage class?
In C, taking the memory address of a register variable using '&' is prohibited.
What happens when a function returns the address of a local automatic variable?
Local auto variables exist on the stack frame which is destroyed upon function return, leaving a dangling pointer.