stl::string 대소문자 전환 (이글루스 예전글)

C++/STL 2008. 11. 27. 17:19
 출처 - http://www.josuttis.com/libbook/string/iter1.cpp.html
 



 string/iter1.cpp


The following code example is taken from the book
The C++ Standard Library - A Tutorial and Reference
by Nicolai M. Josuttis, Addison-Wesley, 1999
© Copyright Nicolai M. Josuttis 1999


#include
#include
#include
#include
using namespace std;

int main()
{
   
// create a string
    string s("The zip code of Hondelage in Germany is 38108");
    cout << "original: " << s << endl;

   
// lowercase all characters
    transform (s.begin(), s.end(),    // source
               s.begin(),             // destination
               tolower);              // operation
    cout << "lowered:  " << s << endl;

   
// uppercase all characters
    transform (s.begin(), s.end(),    // source
               s.begin(),             // destination
               toupper);              // operation
    cout << "uppered:  " << s << endl;
}


: