Array question

closed account (jwkNwA7f)
1
2
3
  string myArray[2] = {"word", "another"};
  string anotherArray[1];
  anotherArray[1] = myArray[0];


How can I get a certain letter of "word" that is in anotherArray?

Thank you!
First of all this statement

anotherArray[1] = myArray[0];

is invalid because anotherArray has only one element with index equal to 0. So the correct code will look as

anotherArray[0] = myArray[0];

Here is an example how to access elements of the element 0 of this array

1
2
3
4
for ( std::string::size_type i = 0; i < anotherArray[0].size(); i++ )
{
   std::cout << anotherArray[0][i];
}
Last edited on
closed account (jwkNwA7f)
Okay, Thank you!
Topic archived. No new replies allowed.