Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
std::string convert code snippet to convert a std::string to upper case.
#include <algorithm> |
Note that in the C++ Builder IDE std::ptr_fun can be called without its template arguments. When using the G++ 4.4.1 compiler leaving out the template arguments results in the compile error No matching function for call to 'ptr_fun'.
StrToUpper can be implemented using a for loop, but prefer algorithm calls over hand-written loops [1][2]. View Exercise #9: No for-loops for other ways of replacing for-loops by algorithms.
#include <cctype> |
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.