...

View Full Version : C/++ Programming



IFeelYourPain
11-29-2008, 06:58 AM
I'm looking to load a text file to input into my options. It will load from the installation directory of C:\install\. I want to load the text file into a variable like so:

option = file.txt;

Not exactly sure how to do this. I researched information on this and have found some ways using open() however I am not sure if this would do what I am needing.

oracleguy
11-29-2008, 06:38 PM
Well there are different ways of doing it depending on if you are using C or C++. Which one are you using?

IFeelYourPain
11-29-2008, 10:20 PM
Well there are different ways of doing it depending on if you are using C or C++. Which one are you using?
It has a combination of both, so C/C++ will work.

oracleguy
11-29-2008, 10:35 PM
The easiest method is using the ifstream class in C++: http://www.cplusplus.com/reference/iostream/ifstream/ifstream.html

IFeelYourPain
11-30-2008, 11:42 PM
is it possible to use it in a variable?

oracleguy
12-01-2008, 01:07 AM
is it possible to use it in a variable?

What do you mean?

IFeelYourPain
12-02-2008, 02:37 AM
What do you mean?

texture = file.txt

So I can load a texture from a text file.

oracleguy
12-02-2008, 07:29 AM
The filename you provide the ifstream class can be from a variable, yes.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum