Reputation: 343
I'm trying to read floats from string splitting them up to 2 integers.
sscanf(line, "%d.%d", &dec, &frac));
This works with strings like this:
"0.25"
But if theres an optional sign before the number, it doesn't work anymore.
"-0.25"
How can i 'tell' sscanf, that there might be an optional sign before the number?
Upvotes: 1
Views: 35
Reputation: 7517
As far as I can see %d
is fine because it is for signed integer, but the issue here comes from the fact that -0
is 0
... You will have to find a workaround since I don't think you can find a clean and easy way for that specific case.
Upvotes: 2