diff --git a/ch03/ex3_22.cpp b/ch03/ex3_22.cpp index ce289a738..0322bb6d9 100644 --- a/ch03/ex3_22.cpp +++ b/ch03/ex3_22.cpp @@ -6,23 +6,21 @@ // #include -#include #include #include -using std::vector; using std::string; using std::cout; using std::cin; using std::isalpha; +using std::string; using std::cout; using std::cin; using std::isalpha; int main() { - vector text; - for (string line; getline(cin, line); text.push_back(line)); + string text; + getline(cin, text); - for (auto& word : text) + for (auto it = text.begin(); it != text.end(); ++it) { - for (auto& ch : word) - if (isalpha(ch)) ch = toupper(ch); - cout << word << " "; + if (isalpha(*it)) *it = toupper(*it); } + cout << text << '\n'; return 0; }