Skip to content

Instantly share code, notes, and snippets.

@bertrandmartel
Last active August 29, 2015 14:20
Show Gist options
  • Save bertrandmartel/fc869b7abe02ec4462e1 to your computer and use it in GitHub Desktop.
Save bertrandmartel/fc869b7abe02ec4462e1 to your computer and use it in GitHub Desktop.
[ CPP ] find if char * is numeric
#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