Vladimir Keleshev
Vladimir Keleshev

Reputation: 14245

sscanf match double

sscanf(str, "%lf", &num);

Here I try to parse a 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?

Upvotes: 0

Views: 599

Answers (1)

K-ballo
K-ballo

Reputation: 81349

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.

Upvotes: 1

Related Questions