Click here to Skip to main content
15,887,881 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I'm working on a program in pure C, and I'm wondering how could I convert a char* to float / int. I know the ato? functions but what I expect is more than that; I'm looking for functions maybe like int str2float(char*, float*) / int str2int(char*, int*) which they return whether the given char* could be a legal numeric format.
I would get a 0.0 if I passed a normal "0.0" or a "something_else" to atof, and get a 3.14 if I passed a "3.14" or a "3.14balabala" to it, that would be terrible for me.
Posted

1 solution

See these[^] functions, I think they will do what you are asking.
 
Share this answer
 
Comments
paladin_t 8-Jan-11 3:45am    
This works fine! Thanks!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900