I have a file which stores values like 2.32x7
.
I read the floating-point part using:
fscanf(file, "%lf", &value);
It works perfectly... except for when the file stores something like 0x2
. In that case, it reads the entire string as a hexadecimal value.
How can I prevent this from happening?
I would like fscanf to just read 0
and ignore x2
.
Edit: As suggested by @dbush, I am adding a sample input file.
I am parsing polynomials. So, the input file will be something like:
0x2+2.32x7-4x-9