okay, so first, i got this code aight.
int readconfig()
{
ifstream hfile("config.ini");
// timelog
theTime1 = CTime::GetCurrentTime();
CString d = theTime1.Format( "%H:%M:%S : " );
// error control
if (hfile == NULL)
{
m_msgData.AddString(d +"Error => Config file could not be opened.");
UpdateData(TRUE);
errorlog("ERROR : Config file could not be opened.");
return 0;
}
else
{
m_msgData.AddString(d +"Read config file with success.");
UpdateData(TRUE);
log("Read config file with success.");
const int sz = 100; // Buffer size;
char buf[sz];
while(hfile.getline(buf, sz))
{
char* cp = buf;
while(*cp != '=')
cp++;
cp += 1; // Past "="
log(buf);
m_msgData.AddString(d +buf);
}
return 0;
}
return 0;
}
okay so this opens the file, reads each line until a break (\n) and then pufs it in a buffer.
the cp is every line after =[this text here goes in cp]
my config.ini file
Logging=0
MaxConnections=100
MinGameVer=01
okay so cp will be
0
100
01
(testet and it is like that)
now to the questions, lets say i want to update a editbox with e.g logging on or off
lets call it m_msgEditBox1
so if Logging=1 it should put that to ON and if its a 0, then it should put that to a OFF.
I know how to put the text into the edit box, but how to i check if the Logging line is a 1 or a 0 ? since all is in the same buffer ?
can you do like a read buffer[1] for line 1 and so ? or how do you do it ?
any help would be appriciatet.
[edited by - Bmsfx on February 26, 2004 1:45:12 PM]