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![]()
This is a discussion on convert char to float within the C++ Programming forums, part of the General Programming Boards category; Hi everyone, i'm kinda stuck with this method of converting char to float. What i'm trying to do is let ...
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.
I used to be an adventurer like you... then I took an arrow to the knee.
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