sscanf match double
sscanf(str, "%lf", &num);
Here I try to parse a开发者_如何学JAVA double.
It catches inf
which is fine.
However it also catches infififi
as inf
, which is wrong in my case.
Other examples would be nandoscope
as nan
and 123abc
as 123
. How to fix this behavior?
That's by design, so it doesn't need fixing. Perhaps you can rewrite your code to read a delimiter after the double, or see if sscanf is reading the whole string.
精彩评论