c++ 大小寫轉換
char 字元大小寫轉換
#include <iostream>
using namespace std;
int main()
{
char c = 'e';
c = toupper(c);//並不會直接覆蓋
cout << c;
system("pause");
return 0;
}
string 字串大小寫轉換
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string str="how are you";
transform(str.begin(),str.end(),str.begin(),::toupper);//第三個引數指定存放轉換後的結果,這裡覆蓋原string
cout << str << endl;
return 0;
}