Last active
August 29, 2015 14:20
-
-
Save bertrandmartel/fc869b7abe02ec4462e1 to your computer and use it in GitHub Desktop.
[ CPP ] find if char * is numeric
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cctype> | |
bool stringutils::isNum(char *s) { | |
int i = 0, flag; | |
while(s[i]){ | |
//if there is a letter in a string then string is not a number | |
if(isalpha(s[i])){ | |
flag = 0; | |
break; | |
} | |
else flag = 1; | |
i++; | |
} | |
if (flag == 1) return true; | |
else return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment