字符串大小写格式化

ctype.h     头文件 

方法1.

static void toLower(std::string& s)
{
 char * buf;
 const char * end = s.c_str() + s.length();
 for( buf = (char*)s.c_str() ; buf != end ;  buf ++ )
 {
  *buf = ::tolower( *buf );
 }
}

tolower(); 转换为小写

toupper();转换为大写 

方法2.

void strtoupper(string s)
{
  for(int i=0;i<strlen(s.c_str());i++)
  cout<< char(toupper(s[i]));
}

原文地址:https://www.cnblogs.com/byfei/p/3112337.html