From 4cf83d3736b0709eb3196f788127853f0304eecb Mon Sep 17 00:00:00 2001 From: Yue Wang Date: Tue, 23 Jun 2015 02:28:50 +1200 Subject: [PATCH] Update ex6_17.cpp --- ch06/ex6_17.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/ch06/ex6_17.cpp b/ch06/ex6_17.cpp index a5a99028..787ca525 100644 --- a/ch06/ex6_17.cpp +++ b/ch06/ex6_17.cpp @@ -1,27 +1,26 @@ #include #include - using std::cout; using std::endl; using std::string; -bool hasUppercase(const string &str) +bool any_capital(string const& str) { - for (auto c : str) - if (isupper(c)) return true; + for (auto ch : str) + if (isupper(ch)) return true; return false; } -void makeLowercase(string &str) +void to_lowercase(string& str) { - for (auto &c : str) - if (isupper(c)) c = tolower(c); + for (auto& ch : str) ch = tolower(ch); } int main() { - string str("Hello World!"); - cout << hasUppercase(str) << endl; - makeLowercase(str); - cout << str << endl; - + string hello("Hello World!"); + cout << any_capital(hello) << endl; + + to_lowercase(hello); + cout << hello << endl; + return 0; }