Hello All.
I need implement method which should read a string from configuration file
and return a part og this string, such as:
"Server port number: 101"
method should return "101".
Code looks like this:
char*
IniFile::readLine(void)
{
char buffer[NAME_MAX_LENGTH];
char *_value;
while (!_iniFile.eof())
{
// read line
_iniFile.getline(buffer, NAME_MAX_LENGTH);
if (strstr(buffer, "Server port name:") == NULL) continue;
_value = strchr(buffer,":");
_value++;
return _value;
}
// nothing found - return 0
return 0;
}
A problem is here: in readline(void) _value is OK. I mean it points to the
correct line. But when "return" is called "buffer" is being destructed,
and the result of the call
char* result = readLine()
is something incredible.
Help me please :-)
Bogdan
--- GoldEd 2.50+ метра
---------------
* Origin: Crematory (2:463/285.82)
|