#include <cctype>
#include <string>
#include <algorithm>
using namespace std;
void ToUpperString(string &str)
{
transform(str.begin(), str.end(), str.begin(), (int (*)(int))toupper);
}
void ToLowerString(string &str)
{
transform(str.begin(), str.end(), str.begin(), (int (*)(int))tolower);
}
#include <string>
#include <algorithm>
using namespace std;
void ToUpperString(string &str)
{
transform(str.begin(), str.end(), str.begin(), (int (*)(int))toupper);
}
void ToLowerString(string &str)
{
transform(str.begin(), str.end(), str.begin(), (int (*)(int))tolower);
}
本文介绍了一种使用C++标准库函数toupper和tolower实现字符串大小写转换的方法。通过两个函数ToUpperString和ToLowerString,可以方便地将字符串全部转换为大写或小写。
3773

被折叠的 条评论
为什么被折叠?



