I want to display all the elements in a vector. My code displays all elements but converts to uppercase just the last one.
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
string words;
string it;
vector<string>list_words;
while (cin>>words)
list_words.push_back(words);
for (auto it = words.begin(); it != words.end() && !isspace(*it); ++it)
*it = toupper(*it);
cout<<list_words.size()<<endl;
cout<<words<<endl;
return 0;
}
Aucun commentaire:
Enregistrer un commentaire