Skip to main content
GameDev.net gamedev.net
🔒 Locked

Need help with ifstream

Started by AeroBLASTER Jul 31, 2002 at 2:34 AM 2 replies 300+ views
Original Post
AeroBLASTER
AeroBLASTER
Basically, what I want to do is retrieve a single number from a .TXT file and put it into a float or integer variable. I''ve looked at a bunch of tutorials, and they all seem to retrieve in the char format. Can anyone help me with a bit of code to do this? Thanks! DirectX gives me a headache.
---DirectX gives me a headache.
SysOp_1101
SysOp_1101
You have to read it in as character(s), then use a function like atoi or atof to convert it to what you want. Unless you are using fixed point numbers however, you still have the problem od distinguishing one number from another (unless each number is on a seperate line).

[edited by - SysOp_1101 on July 31, 2002 3:43:07 AM]
SysOp_1101
AeroBLASTER
AeroBLASTER
no, each text file just contains a single number.

Now, if I may ask a newbie question, how do I use the functions you mentioned?
---DirectX gives me a headache.
AeroBLASTER
AeroBLASTER
nevermind, got it working Thanks for the help!
---DirectX gives me a headache.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.