ifstream og ofstream?
Hejsa. Kan nogen sige mig hvorfor følgende stykke kode ikke kan indlæse værdierne fra min fil men kun kan skrive dem ud til den?/*********************************************************/
/*************** ---> START OF: ***************/
/*************** Deacon's Config System ***************/
/*************** http://www.macrotech.dk ***************/
/*********************************************************/
class cfg_system
{
private:
char *cfg_file;
char *variable;
float value;
ifstream read;
ofstream write;
public:
void load(void)
{
cfg_file = "flamegl.cfg";
read.open (cfg_file);
while (read >> variable >> value)
{
if (!strcmp(variable, "wallhack")) { wallhack = (int)value; }
if (!strcmp(variable, "entity")) { entity = (int)value; }
if (!strcmp(variable, "modalwire")) { modalwire = (int)value; }
if (!strcmp(variable, "crosshair")) { crosshair = (int)value; }
if (!strcmp(variable, "mouse2")) { mouse2 = (int)value; }
if (!strcmp(variable, "lambert")) { lambert = (int)value; }
if (!strcmp(variable, "Credits")) { Credits = (int)value; }
read.close();
}
}
void save(void)
{
cfg_file = "flamegl.cfg";
write.open (cfg_file);
write << "wallhack " << (int)wallhack << endl;
write << "entity " << (int)entity << endl;
write << "modalwire " << (int)modalwire << endl;
write << "crosshair " << (int)crosshair << endl;
write << "mouse2 " << (int)mouse2 << endl;
write << "lambert " << (int)lambert << endl;
write << "Credits " << (int)Credits << endl;
}
} settings;
/*********************************************************/