Mar 2, 2012 at 9:58am UTC
Hello!! I have my tests coming up..
Can someone please teach me character arrays.
Last edited on Mar 2, 2012 at 3:23pm UTC
Mar 2, 2012 at 10:09am UTC
What? Character arrays are arrays of characters. Done. Do I get to charge a tuition fee?
Mar 2, 2012 at 10:10am UTC
They're just like every other kind of array, but with char as the type.
Mar 2, 2012 at 10:56am UTC
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 Mar 2, 2012 at 10:57am UTC