1.直接处理vector类型的对象
vector<string> text{"Hello World!!!"};
for (auto it = text.begin(); it != text.end() && !it->empty(); ++it)
{
*it = toupper(*it);
cout << *it << endl;
}
应改为:
vector<string> text{"Hello World!!!"};
for (auto it = text.begin(); it != text.end() && !it->empty(); ++it)
{
for (auto &c : *it)
{
if(isalpha(c)) c = toupper(c);
}
}
for (auto it : text)
{
cout << it << endl;
}