Multiple choice

char txt [20] = Hello world!;

How many bytes are allocated by the definition above?

  1. 11

  2. 12

  3. 13

  4. 20

  5. 21

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The array declaration char txt[20] allocates 20 bytes of memory, regardless of the initial string length. Even though 'Hello world!' is only 12 characters (plus null terminator = 13 bytes), the full 20 bytes are reserved as declared.