Difficulty: Easy
Correct Answer: 24, 5
Explanation:
Introduction / Context:
This checks your understanding of sizeof with arrays of pointers versus the length of a pointed-to string via strlen. Pointer size is specified as 4 bytes to make the arithmetic straightforward and portable for the question’s context.
Given Data / Assumptions:
Concept / Approach:
sizeof on an array yields the total bytes of the array object, not the sum of the lengths of target strings. strlen counts characters until the terminating '\0' in the referenced string.
Step-by-Step Solution:
Verification / Alternative check:
If the pointer size were 8 bytes (common on 64-bit systems), sizeof(str) would be 48; the second value would still be 5.
Why Other Options Are Wrong:
Common Pitfalls:
Confusing sizeof(pointer) with strlen of the pointed-to string; forgetting that sizeof on an array does not decay inside the sizeof operator.
Final Answer:
24, 5.
Discussion & Comments