So i have this string:
1, 3.8 , 4.0 , 2 e
And this function that split my string
with comma
and tab
and print my numbers:
void readuserinput(char *ch)
{
ch = strtok(ch, ", \t");
char *ptr;
double ret;
while (ch)
{
ret = strtod(ch, &ptr);
double d = atof(ch);
printf("%f", d);
ch = strtok(NULL, ", \t");
}
}
So in case i have non number for example e
, any chance to check it and in case this is not number print error ?
Is C Language have double
parse or something like that ?