Difficulty: Easy
Correct Answer: a null character
Explanation:
Introduction / Context:In C and C++, a string literal such as "Hello" is stored as an array of characters terminated by a special character. Recognizing this terminator is crucial when working with C-style strings, pointer arithmetic, standard library functions like strlen, and interfacing with APIs that expect null-terminated strings.
Given Data / Assumptions:
Concept / Approach:
Step-by-Step Solution:
Take "Hi": underlying storage is {'H', 'i', '\0'}.For "Hello": storage is 6 chars → 'H' 'e' 'l' 'l' 'o' '\0'.Therefore, the automatically appended character is the null character.Verification / Alternative check:
sizeof("Hello") equals 6 (including terminator) while strlen("Hello") equals 5 (excluding terminator), confirming presence of '\0'.Why Other Options Are Wrong:
Common Pitfalls:
Final Answer:
a null character
Discussion & Comments