Mailinglist Archive: opensuse (2532 mails)

< Previous Next >
Re: [opensuse] strtof problem - what am I doing wrong?
  • From: Randall R Schulz <rschulz@xxxxxxxxx>
  • Date: Sat, 3 May 2008 19:16:17 -0700
  • Message-id: <200805031916.17378.rschulz@xxxxxxxxx>
On Saturday 03 May 2008 19:00, Sam Clemens wrote:
...

endptr is uninitialized,
so it's pointing at some random memory location.

While it's true that the declaration of endptr leaves it uninitialized,
that is not the problem. Strtof's second argument is **char. Strtof
stores into this pointer (to a pointer to char) the pointer to the
first character that was not used in translating the string into a
float value. Calling strtof() with &endptr as its second argument is
correct.

Thus this is not the source of the problem. It is rather, as Anders
states, that the compiler had not been told anything about strtof(),
and called in the old, old C default way (as if it returns an int ...
what else?).


...


Randall Schulz
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >