前言
现代C++
中的大写字符串转小写字符串的一种实现。
一、包含算法库头文件
#include <algorithm>
二、验证
在main函数中写下如下代码
编译执行g++ test.cpp -o test && ./test
结果如下
大写转小写成功!!!。
三、完整代码
完整代码如下
#include <algorithm>
#include <iostream>
#include <string>
int main(int argc, char* argv[])
{
std::string s { "QWERTYUIOP" };
std::transform(s.begin(), s.end(), s.begin(), ::tolower);
std::cout << s << std::endl;
return 0;
}
四、总结
本文介绍一种现代C++中将大写字符串转换成小写字符串的方法,亲测可用!!!