使用C ++中的STL将整个字符串转换为大写或小写
在本教程中,我们将讨论一个程序,以了解使用C++中的STL将整个字符串转换为大写或小写的方法。
为了执行此转换,C++STL提供toupper()和tolower()函数以分别转换为大写和小写。
示例
#include<bits/stdc++.h>
using namespace std;
int main(){
string su = "nhooo.com";
transform(su.begin(), su.end(), su.begin(), ::toupper);
cout << su << endl;
string sl = "nhooo.com";
transform(sl.begin(), sl.end(), sl.begin(), ::tolower);
cout << sl << endl;
return 0;
}输出结果
nhooo.com nhooo.com
热门推荐
10 孙媳妇祝福语简短
11 古风中考祝福语简短
12 简短祝福语蛋糕简笔画
13 新年祝同学祝福语简短
14 毕业祝福语简短英语小学
15 恭喜订婚的祝福语简短
16 生日寿宴祝福语简短精辟
17 年后祝福语简短走心
18 学生祝福语简短古诗句