|
From: Per W. <pw...@ia...> - 2003-01-28 08:42:11
|
sscanf can convert one or multiplie parameters from a text string into corresponding variables. The problem is that you have very little control of what sscanf considers white characters etc. And in case of a conversion problem, it isn't easy to point exactly at the failing character. With strtod, you get a pointer to the first un-processed character of your input string. For a parser, the normal action is to process characters one at a time - that means that strotod is never called unless the parser knows that the first character is the start of a number, i.e. the next character to process is 0-9 or a decimal separator (. or , depending on locale). Uppon return of atrtod, the parser may then immediately continue parsing at the endptr position. /Per W On Sun, 19 Jan 2003, Ioannis Vranos wrote: > ------Original Message------- > > From: Per Westermark > Date: Sunday, 19 January 2003 10:48:26 PM > To: j b > Cc: dev...@li... > Subject: Re: [Dev-C++] atof 2... > > Hello! > > Don't use atof() for converting from text string to a double. > > Use strtod() instead, since it will inform you how many characters it > consumed. > > > > ==> What about sscanf()? > > > > Ioannis Vranos > > * Programming pages: http://www.noicys.freeurl.com > * Alternative URL: http://run.to/noicys |