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;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
scanf,operator>>for istreams, andstrtofwould be the obvious choices.There is also
atof, but, likeatoi, it lacks a way to tell you there was an error in the input, so it’s generally best to avoid both.