Question
The output has only 19 bytes even though the name array has the size of 20 bytes, why is that?
The output has only 19 bytes even though the name array has the size of 20 bytes, why is that?
Hello,
Good question that is because we use a NULL terminator which is basically a byte thats equal to zero. This is what tells printf that a string has ended. When ever you define a string in C a NULL terminator is automatically prepended in memory. For example if we did printf("Hello"); the Hello looks like this in memory 'H', 'e', 'l', 'l, 'o', 0x00
Does that answer your question?