快 2026 年了,C++ 转换大小写为什么还是如此垃圾?

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#include <iostream>
#include <algorithm>
#include <cctype>
#include <string>

int main() {
    std::string s = "Hello World!";
    std::transform(s.begin(), s.end(), s.begin(),
                   [](unsigned char c){ return std::toupper(c); });
    std::cout << s << std::endl; // 输出:HELLO WORLD!
    return 0;
}

学学隔壁 Swift 写 extension 吧。

geniusvczh on X: "@pK7qkLEE6TKEBRs 用stl🤪" / X

陪她去流浪 碎碎念 桃子