几种字符串字母大小写转换方法
转载
- 使用c++
#include <algorithm>
#include <string>
std::string str = "Hello World";
std::transform(str.begin(), str.end(),str.begin(), ::toupper);
- 使用boost库
#include <boost/algorithm/string.hpp>
#include <string>
std::string str = "Hello World";
boost::to_upper(str);
std::string newstr = boost::to_upper_copy<std::string>("Hello World");
- c++11循环处理
for (auto & c: str) c = toupper(c);