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.