Share
Explore BrainMass

What character array's size would be large enough to hold "H

In the following example, why would we declare an array of 4 instead of 3?

#include <stdio.h>

void main (void)
{
/* arrays */
char id[4] = "POS";
short qty[3] = {33, 37, 30};
}

What character array's size would be large enough to hold "Hello world"?

Solution Preview

The string "POS" contains in fact one extra character whose numerical value is 0.
By convention, this type of strings must necessarily end with the zero character.

The string ...

$2.19