N
nvangogh
The problem is to read a sequence of words from cin and store the values
in a vector. After you have read all the words, process the vector and
change each word to upper case. Print the transformed elements.
I have done the first part - storing all words in a vector, but I cannot
seem to access each element of the vector and change each letter to
upper case.
-------------
int main()
{
vector<string> collection;
string aword;
cout << "Input some words in lowercase and see them transformed! type
'end' to end input" << endl;
while(cin >> aword)
{
if(aword != "end")
collection.push_back(aword);
else
break;
}
// process the vector
auto sz = collection.size(); // sz the number of elements in the vector
int index = 0;
while(index <= sz)
{
for(auto &c : collection[index];
{
c = toupper(c);
}
++index;
}
return 0;
}
This does not even compile. Can someone please show me how to do it?
in a vector. After you have read all the words, process the vector and
change each word to upper case. Print the transformed elements.
I have done the first part - storing all words in a vector, but I cannot
seem to access each element of the vector and change each letter to
upper case.
-------------
int main()
{
vector<string> collection;
string aword;
cout << "Input some words in lowercase and see them transformed! type
'end' to end input" << endl;
while(cin >> aword)
{
if(aword != "end")
collection.push_back(aword);
else
break;
}
// process the vector
auto sz = collection.size(); // sz the number of elements in the vector
int index = 0;
while(index <= sz)
{
for(auto &c : collection[index];
{
c = toupper(c);
}
++index;
}
return 0;
}
This does not even compile. Can someone please show me how to do it?