Horje
know what the input data is whether integer or not Code Example
know what the input data is whether integer or not
#include <iostream>

using std::cout;
using std::cin;
using std::endl
using std::string;

bool isNumber(const string& str)
{
    for (char const &c : str) {
        if (std::isdigit(c) == 0) return false;
    }
    return true;
}

int main(){
    string str1 = "231524randstr23";
    string str2 = "23152423";
    string str3 = "a3152423";

    isNumber(str1) ? cout << "Number\n" : cout << "Not number\n";
    isNumber(str2) ? cout << "Number\n" : cout << "Not number\n";
    isNumber(str3) ? cout << "Number\n" : cout << "Not number\n";

    return EXIT_SUCCESS;
}




Cpp

Related
recherche sur les dangers de quelques matériaux Code Example recherche sur les dangers de quelques matériaux Code Example
c++ for loop Code Example c++ for loop Code Example
c++ programming Code Example c++ programming Code Example
npm wasm Code Example npm wasm Code Example
how can I delete a substring from a string in c++? Code Example how can I delete a substring from a string in c++? Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
16