【发布时间】:2022-09-27 15:18:08
【问题描述】:
我必须确定输入是数字还是字符串。
std::string s;
while (std::cin >> s) {
if(isdigit(s)){
//do something with the variable
}
else{
//do something else with the variable
}
}
为此我得到
error: no matching function for call to \'isdigit(std::__cxx11::string&)\'
有人可以提出我应该使用的方法吗?
-
有
std::isdigit(),但它不带字符串;它需要性格。
标签: c++ cin stdstring typechecking