[Solved] character and array [closed]


char name;

This gives you a single char object.

char name[5];

This gives you 5 char objects, one after the other – this is called an array of 5 chars. You can index them with name[0], name[1]… until name[4].

"best"

This is a string literal. It represents an array of 5 chars in read-only memory, containing the characters b, e, s, t, and \0.

char name[5] = "best";

This declares an array of 5 chars, as before, and initialises each of the elements of that array with the elements of the string literal. The name array will now also contain the characters b, e, s, t, and \0.

1

solved character and array [closed]