使用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 祝福语驱散霉运的话简短