c++用bool函数判断字符是否为数字,是则ture,否则false
#include <iostream>
using namespace std;
int main()
{
bool flag = false;
char c;
cin >> c;
if(c <= '9' && c >= '0'){
flag = true;
}
cout << flag << endl;
return 0;
}
直接判断字符的值是否在'0'到'9'之间