所以,我一直在做 Reddit 的 daily programmer #140并且不能使用 std::toupper 和 std::erase。
包括:
#include <iostream>
#include <string>
#include <cctype>
部分与 toupper 和 erase(用于将单词转换为“CamelCase”):
std::string tekst;
std::cin >> tekst;
tekst[0] = std::touppper(tekst[0]);
for(unsigned int i = 0; i < tekst.size(); i++){
if(tekst[i] == 32){
std::erase(tekst[i], 1);
tekst[i] = std::toupper(tekst[i]);
}
}
编译器显示错误:
error: 'touppper' is not a member of 'std'
error: 'erase' is not a member of 'std'
什么会导致它?提前致谢!
最佳答案
不是
std::touppper
但是
std::toupper
您需要将语言环境传递给函数,例如:http://www.cplusplus.com/reference/locale/toupper/
关于c++ - 找不到 toupper 并删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19882561/