小编kay*_*orr的帖子

std::cin>> 是数字或字符串

我必须确定输入是数字还是字符串。

std::string s;
while (std::cin >> s) { 
    if(isdigit(s)){
        //do something with the variable
    }
    else{
        //do something else with the variable
    }
}
Run Code Online (Sandbox Code Playgroud)

为此,我得到 error: no matching function for call to 'isdigit(std::__cxx11::string&)' 有人可以提出我应该使用的方法吗?

c++ cin stdstring typechecking

0
推荐指数
1
解决办法
142
查看次数

标签 统计

c++ ×1

cin ×1

stdstring ×1

typechecking ×1