Hi all,
Sorry for the stupid question... but I havn't used C very often...
How do I convert a string into float?
THANKS!!!
Liat.
This is a discussion on type casting within the C Programming forums, part of the General Programming Boards category; Hi all, Sorry for the stupid question... but I havn't used C very often... How do I convert a string ...
Hi all,
Sorry for the stupid question... but I havn't used C very often...
How do I convert a string into float?
THANKS!!!
Liat.
Thanks!!!
I tried atof() and that seems to work fine.
Any major resons to use something else? (are there advantages for using the others?)
Thanks again!
Liat.
strtod() and strtof() allow you to detect if the string isn't a double or float respectively and be able to write a complicated routine to figure out how you want to proceed.
sscanf() has more or less the same limitations of scanf(). It allows some error handling but not as much as strtod() or strtof().