UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » C
  • » scanf problems

#26 2009-03-20 09:35 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: scanf problems

Ah, yeah, isnan() is definitely the prefered way of doing things...  Though, I'm surprised
that the "== NAN" would eval true for all numbers, too... *shrug*

In fact, you can probably just go with a single call to isnormal(), and complain about
anything else...  (Though, you still want the "p == buf" test to catch cases where
nothing was parsed at all...  And, you might want to throw in a test for 0 and
"errno == ERANGE", since it looks like that is really the underflow condition, not
negative infinity (ie: -HUGE_VAL)...

Offline

  • Index
  • » C
  • » scanf problems

Board footer

Powered by FluxBB