|
From: Ioannis V. <no...@ho...> - 2003-01-28 09:18:27
|
-------Original Message-------=0D =0D From: Per Westermark=0D Date: =D4=F1=DF=F4=E7, 28 =C9=E1=ED=EF=F5=DC=F1=E9=EF=F2 2003 10:43:25 =F0= =EC=0D To: Ioannis Vranos=0D Cc: dev...@li...=0D Subject: Re: [Dev-C++] atof 2...=0D =0D sscanf can convert one or multiplie parameters from a text string into=0D corresponding variables. The problem is that you have very little control= =0D of what sscanf considers white characters etc. And in case of a conversio= n=0D problem, it isn't easy to point exactly at the failing character.=0D =0D With strtod, you get a pointer to the first un-processed character of you= r=0D input string. For a parser, the normal action is to process characters on= e=0D at a time - that means that strotod is never called unless the parser=0D knows that the first character is the start of a number, i.e. the next=0D character to process is 0-9 or a decimal separator (. or , depending=0D on locale). Uppon return of atrtod, the parser may then immediately=0D continue parsing at the endptr position.=0D =0D /Per W=0D =0D =0D =3D=3D> Yes it's a nice for-double-only valid way too. But i prefer sscan= f() for all this kind of stuff. :)=0D =0D =0D Ioannis Vranos=0D =0D * Programming pages: http://www.noicys.freeurl.com=0D * Alternative URL: http://run.to/noicys=20 |