C++ 数値チェック

文字列の数値チェック関数

この関数で以下の判定が可能である。
❌10.1 、-5、1A、abc
⭕️1、5、05、10

#include <algorithm>
bool checkint(std::string str) {
if (std::all_of(str.cbegin(), str.cend(), isdigit)) {
return true;
}
else {
return false;
}
}

コメント

人気の投稿