string 大小写转换

#include <string>  
#include <algorithm>  
using namespace std;  

int main()  
{  
        string strA = "yasaken@126.com";  
        string strB = "LURY@LENOVO.com";  
        printf("Before transform:
");  
        printf("strA:%s 
", strA.c_str());  
        printf("strB:%s 

", strB.c_str());  

        transform(strA.begin(), strA.end(), strA.begin(), ::toupper);  
        transform(strB.begin(), strB.end(), strB.begin(), ::toupper);  
        printf("After transform to toupper:
");  
        printf("strA:%s 
", strA.c_str());  
        printf("strB:%s 

", strB.c_str());  

        transform(strA.begin(), strA.end(), strA.begin(), ::tolower);  
        transform(strB.begin(), strB.end(), strB.begin(), ::tolower);  
        printf("After transform to lower:
");  
        printf("strA:%s 
", strA.c_str());  
        printf("strB:%s 

", strB.c_str());  
        return 0;  
}
原文地址:https://www.cnblogs.com/laohaozi/p/8266498.html