cplusplus-primer-5ed-notes/part_i/ch03_4_1.cpp

27 lines
472 B
C++

#include <string>
#include <iostream>
using std::string; using std::cout; using std::endl;
int main(int argc, char const *argv[])
{
string s("some string");
// if (s.begin() != s.end())
// {
// auto it = s.begin();
// *it = toupper(*it);
// }
for (auto it = s.begin(); it != s.end() && !isspace(*it); ++it)
{
*it = toupper(*it); // capitalize the current character
}
cout << (s) << endl;
return 0;
}