Difficulty: Medium
Correct Answer: 1022 Hello2
Explanation:
Introduction / Context:
This question examines pointer types with string literals, how the unary & operator changes the type, and how printf interprets arguments for %u and %s. It also assumes a specific address (1022) for the literal 'Hello1' to make the numeric output deterministic.
Given Data / Assumptions:
Concept / Approach:
Although the pointer types are not char*, the numeric value of &'Hello1' prints as the base address. For %s, &'Hello2' is treated as the base address of the literal string. On many older compilers, this prints correctly despite the subtle type mismatch (on modern compilers, you would cast explicitly).
Step-by-Step Solution:
Verification / Alternative check:
Replacing &'Hello2' with 'Hello2' (which decays to char*) still prints 'Hello2'. Both point to the same base address.
Why Other Options Are Wrong:
Common Pitfalls:
Confusing &'literal' with the decayed char* of a literal; assuming %s requires exactly char* and not recognizing platform permissiveness in old toolchains.
Final Answer:
1022 Hello2.
Discussion & Comments