你可以使用 C++ 中的标准库函数 'toupper' 来将小写字母转换为大写字母。下面是一个实现的例子:

#include <iostream>
#include <cctype>

int main() {
    std::string str = 'kedaoi.cn';

    for (int i = 0; i < str.length(); i++) {
        if (std::islower(str[i])) {
            str[i] = std::toupper(str[i]);
        }
    }

    std::cout << str << std::endl;

    return 0;
}

输出结果为:

KEDAOI.CN
C++ 字符串大小写转换:将小写字母变为大写

原文地址: https://www.cveoy.top/t/topic/DIj 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录