Hi everyone, i'm kinda stuck with this method of converting char to float. What i'm trying to do is let the user enters the amount of money in character variable, then convert it into float variable. Please help, thanks![]()
Hi everyone, i'm kinda stuck with this method of converting char to float. What i'm trying to do is let the user enters the amount of money in character variable, then convert it into float variable. Please help, thanks![]()
Hello, testing testing. Everthing is running perfectly...for now
Post what you have.....Why are you using a char for the input?
Just do a search at google for "C++ ATOF"
The mighty stringstream is your friend.
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens
BTW, a char holds a single character. You probably mean to say character array or string. In which case a stringstream (or atof, or sprintf) is the way to go.
The code is use for OpenGL, the typing function use an array of character to accept the user input. That is why i have to convert from char to float. It is for default price for an object. The adminstration input a default price. ThanksOriginally Posted by chadsxe
Hello, testing testing. Everthing is running perfectly...for now
Never mind guys, my problem was that i convert the string character before i enter the value, which it will automatic give a 0 value for the variable. Thank you anyway![]()
Hello, testing testing. Everthing is running perfectly...for now