Please forgive me if this is a 'dumb' question, but I am not much of a C coder.
I am working on some routines to be used in a different language. One of the routines I want is a check to see if a string is numeric (like the VB command). This is what I have come up with:
Code:
int IsNumeric(char *pString){
char *pEnd;
double dbl;
dbl = strtod (pString,&pEnd);
if (pString != pEnd && *pEnd == '\0'){
//it is numeric
return 0;
}
else{
//it isn't
return -1;
}
} I have tried a few tests with it and it seems to work, but I am great for over looking obvious.
Thanks for helping a bad c coder.