C++将字符串转换成大写、小写的函数
#include <string> std::string toLower( std::string str ) { for ( int i = 0; i < str.length(); i++ ) { /* Only convert upper-case letters */ if ( str[i] > 64 && str[i] < 91 ) str[i] += 32; } return str; } std::string toUpper( std::string str ) { for ( int i = 0; i < str.length(); i++ ) { /* Only convert lower-case letters */ if ( str[i] > 96 && str[i] < 123 ) str[i] -= 32; } return str; } bool isNpos( size_t iter ) { return iter == std::string::npos; }