-
type checking
Basically I have a file with random words and some double values; there is no apparent structure in the structure I've written the code to read the file and pass it into an array.
So now Is there a way to check whether each element in the array contain characters or numbers?
The goal is to seperate the numeric values and flush them into a file.
-
You can easily test a string to see if it's numeric. If they're floating-point values, the easiest way is to try to convert the string to a double with strtod:
Code:
char *end;
double d = strtod ( line, &end );
if ( end != line && *end != '\0' ) {
/* Not a number */
}