使用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 妈妈生日祝福语简短励志