开发者

sscanf match double

开发者 https://www.devze.com 2023-04-04 17:09 出处:网络
sscanf(str, \"%lf\", &num); Here I try to parse a开发者_如何学JAVA double. It catches inf which is fine.
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.

0

精彩评论

暂无评论...
验证码 换一张
取 消