Arrays

I was wondering how to make it so the user enters text and the computer enters that into an array. Something like this:
1
2
3
4
string word [5];
cout << "Enter \"Hello\": "
cin >> word;
cout << "Letter 1 was: " << word [1]



Thanks In Advance and thank you for the help, I learn better from people than from tutorials.
Last edited on
cin >> word[0];
will read the input in an element of the array
How can I make it so it remembers hello for instance? Do I do this?
1
2
3
4
string word [5];
cout << "Enter \"Hello\": "
cin >> word[1], [2], [3], [4], [5];
cout << "Letter 1 was: " << word [1]
indexes start at [0], not [1].

And the comma operator doesn't work that way.

You don't need an array of strings for this:

1
2
3
4
5
6
string word;

cout << "Enter \"Hello\": ";
cin >> word;
cout << "you entered: " << word << endl;
cout << "the first letter of that word is: " << word[0] << endl;
THANK YOU!!!
Topic archived. No new replies allowed.