Reputation: 61
cout << "Input text:\n";
cin >> tex;
take tex
and put it into an array of whatever size?
for example, if I inputted "hello"
, get an array that is something like
array[x] = {'h', 'e', 'l', 'l', 'o'}
I would then have a for loop that performs something on each letter (which I know how to do) but then how do I make it stop at the end?
Upvotes: 0
Views: 56
Reputation: 190
for a standard string, use below.
cout << "Input text:\n";
cin >> tex;
for(std::string::iterator it = tex.begin(); it != tex.end(); ++it) {
//your work
}
or
for (int i = 0; i < tex.size(); i++){
cout << tex[i];
}
Upvotes: 1