Reading Files :doh:
-
Hello, ok my problem is that i don't know how to parse a config file. The file is read line by line into a char[255]. The config file looks like this:
some_proberty = some_value
test2 = test3
url = www.codeproject.comSo there is always the name an then = and then the value. In Visual C++ I would use CStrings which have the Trim, Left, Right Functions, etc. But it seems there are no such functions for the char. So how can I read my config file ? With best regards, Benedikt
-
Hello, ok my problem is that i don't know how to parse a config file. The file is read line by line into a char[255]. The config file looks like this:
some_proberty = some_value
test2 = test3
url = www.codeproject.comSo there is always the name an then = and then the value. In Visual C++ I would use CStrings which have the Trim, Left, Right Functions, etc. But it seems there are no such functions for the char. So how can I read my config file ? With best regards, Benedikt
Red, you may be able to use sscanf to parse each line of the file. It can parse based on a format string into the variables that are passed in the call to it. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_sscanf.2c_.swscanf.asp[^]
-
Red, you may be able to use sscanf to parse each line of the file. It can parse based on a format string into the variables that are passed in the call to it. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_sscanf.2c_.swscanf.asp[^]
Thank you !!!!:-D
-
Hello, ok my problem is that i don't know how to parse a config file. The file is read line by line into a char[255]. The config file looks like this:
some_proberty = some_value
test2 = test3
url = www.codeproject.comSo there is always the name an then = and then the value. In Visual C++ I would use CStrings which have the Trim, Left, Right Functions, etc. But it seems there are no such functions for the char. So how can I read my config file ? With best regards, Benedikt
-
Hello, ok my problem is that i don't know how to parse a config file. The file is read line by line into a char[255]. The config file looks like this:
some_proberty = some_value
test2 = test3
url = www.codeproject.comSo there is always the name an then = and then the value. In Visual C++ I would use CStrings which have the Trim, Left, Right Functions, etc. But it seems there are no such functions for the char. So how can I read my config file ? With best regards, Benedikt
RedDragon2k wrote:
In Visual C++ I would use CStrings which have the Trim, Left, Right Functions, etc. But it seems there are no such functions for the char.
Sure there is. If they did not exist for
char
, then theCString
class would not have such methods (since it is based on achar
type). Why not just copy the code from the threeCString
methods into your project? It'll work fine.
"Take only what you need and leave the land as you found it." - Native American Proverb
-
Hello, ok my problem is that i don't know how to parse a config file. The file is read line by line into a char[255]. The config file looks like this:
some_proberty = some_value
test2 = test3
url = www.codeproject.comSo there is always the name an then = and then the value. In Visual C++ I would use CStrings which have the Trim, Left, Right Functions, etc. But it seems there are no such functions for the char. So how can I read my config file ? With best regards, Benedikt
RedDragon2k wrote:
ok my problem is that i don't know how to parse a config file. The file is read line by line into a char[255]. The config file looks like this:
Two Option :- #1. Use GetPrivateProfileString() api to extract data from file #2. use CStdioFile::ReadString() method (which read the File Line by line) and then you have to parse the data manaully
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV