1st of all, the array space starts from 0 ( space[0] ) and ends at 8 ( space[8] );
and you can give them values like you said, but starting from space[0] and ending at space [8], or you can enter them from your keyboard, by using
1 2 3 4
for(int i=0; i < the number you have between[ ] when you set the array; i++)
{
cin>>space[i];
}
You can't cin>> a string...you have to use getline(). However, I would suggest you just make your array an array of chars since you only have having 1 character per unit. And yes, array space[9] allocates space from [0]-[8] and if you access above that, bad things happen...
Dear Sir,
When we declare global variable it does not mean that variable is constant,it simply means that if value of that variable is changed in the program then after that the changed value is used not the earlier value.Moreover in string data type array will be initialized as:
space[9] = { "harry", "tom", "jenny", "doly", "diana", "jhon",
"adam", "anthony", "michel" }
Hope this will help you.
With Regards,
Matanuragi