Problem with character arrays

Hello!! I have my tests coming up..
Can someone please teach me character arrays.
Last edited on
What? Character arrays are arrays of characters. Done. Do I get to charge a tuition fee?
They're just like every other kind of array, but with char as the type.
Usually character arrays simulate character literals by having terminate zero character.
The big difference between character arrays and arrays of other types is that most ouput routines can display character arrays.

For example

1
2
char s[6] = "Hello";
int a[6] = { 'H', 'e', 'l', 'l', 'o', '\0' };


It looks like the two arrays are similar. However the first one can be displayed while the second one not.

1
2
std:;cout << s << std::endl; // O'k
std:;cout << a << std::endl; // error 
Last edited on
Topic archived. No new replies allowed.