Character Arrays
You can have an array of any data type : integer, float etc...
You can even have character arrays. Character arrays are used to store strings. String means a series of characters. You know that the character data type can take in only a single character. Whereas a character array can take in a number of characters. The size depends on the size of the array.
Example :
char name[10];
The above declaration declares an array of
character type that can store 10 characters. The name of the array is name.
// A program getting the name of a person and
displaying the name
# include <iostream.h>
int main ( )
{
char name[15];
cout<< "Enter your name : ";
cin>> name;
cout<< "Your name is "<<name;
return 0;
}
Go to the next section on : Beware of what you store in character arrays
or Go back to Contents
Copyright © 2002 Sethu Subramanian All rights reserved.