'Prevent sscanf from reading anything but a double in input file

I am trying to implement a parser. The input file has this form:

[Boundary1]

char* Boundary_type double Boundary_value;

[Boundary2]

etc...

In short this is how I do it:

fgets(buffer,128,my_file);
sscanf(buffer,"%[^ ] %lf;",bmarker_type,&value);

I want to stop the program if Boundary_value reads anything that's not a double, for example if there's an input mistake from the user. I've tried reading Boundary_value as a char*, then using strtod(str_value,NULL) to convert it to a double. Problem is strtod returns 0.00000 if it's not possible, which is bad if the boundary value is actually 0, so I can't use that as a check.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source