I'm wondering what sort of algorithm could be used to take something like "4.72" into a float data type, equal to
float x = 4.72;
scanf, operator>> for istreams, and strtof would be the obvious choices.
scanf
operator>>
strtof
There is also atof, but, like atoi, it lacks a way to tell you there was an error in the input, so it's generally best to avoid both.
atof
atoi
2.1m questions
2.1m answers
60 comments
57.0k users