c++ check if a string is a number code example
Example 1: c++ is string a number
bool isStringNumber(string str){
for(int i=0;i<str.length();i++){
if(str[i]<'0'||str[i]>'9'){
return false;
}
}
return true;
}
//Beleive in Allah!
//just my slogan
Example 2: how to check whether input is string or not
num = input("Enter your number ")
print("\n")
if num.isdigit():
print("User input is Number ")
else:
print("User input is string ")