Go Back   Flash Flash Revolution > General Discussion > Chit Chat
Register FAQ Community Calendar Today's Posts Search

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 09-15-2005, 07:27 PM   #11
ad0gg
FFR Player
 
Join Date: Dec 2003
Location: At My House
Posts: 989
Default Re: RE: Re: C++ Help

Quote:
Originally Posted by soccr743
Qreepy, you read from the console into the buffer which is in char* format... Then, you would need to convert that to a float in order to use it in calculations.
The function to convert a char * to a float is atof, with its only argument a char * and it returns a value of type float. It is found in in the stdlib.h header file. So you would use it like this:
Code:
#include <iostream>
#include <stdlib>
using namespace std;

int main()
{
        char asdfString[5] = "54.2";
        float asdfFloat;

        asdfFloat = atof(asdfString);

        return 0;
}
...and Voila, you can then use asdfFloat in calculations. The atoi function is exactly the same as the atof function, but it returns an integer value instead.
__________________
ad0gg is offline   Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 12:49 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Copyright FlashFlashRevolution