GetPrivateProfileString Reading Section With Multiple Keys
I want to know if it is possible to use GetPrivateProfileString to read a section where the keys are duplicate. I try it, but I can only retreive one key. This is my file format
[Section Name]
KeyOne = ItemOne
KeyOne = ItemTwo
KeyOne = ItemThree
For any reason, I can only retrieve item one. I want to know and how if I can format GetPrivateString in a form, where the first time it executes it will retrieve keyone from the first line, then go to the next line to read the next keyone.
Re: GetPrivateProfileString Reading Section With Multiple Keys
Quote:
if it is possible to use GetPrivateProfileString to read a section where the keys are duplicate.
No.
Put 2 red sweaters in a box, and ask a bystander to get 'the red sweater' out of the box. The first question you get is 'which red sweater'. That's why you can only retrieve 1 item.
Re: GetPrivateProfileString Reading Section With Multiple Keys
Why are you having the same names in the first place ?
Re: GetPrivateProfileString Reading Section With Multiple Keys
In this case, I may need to use getline from std library to retrieve the items which are duplicate. So how can I use getline in this particular case?
Re: GetPrivateProfileString Reading Section With Multiple Keys
A better question is why do you have duplicates and how can you remove them.
Re: GetPrivateProfileString Reading Section With Multiple Keys
I try to use getline, but getline only stop reading before delimiter. I want to start reading after '=', not before. Is there a way I can modify it.
PHP Code:
streamFile.getline(myChar, 10, '=');
Re: GetPrivateProfileString Reading Section With Multiple Keys
A better question is why do you have duplicates and how can you remove them
Re: GetPrivateProfileString Reading Section With Multiple Keys
this is not an .ini file. It is an special purpose text file
Re: GetPrivateProfileString Reading Section With Multiple Keys
Quote:
Originally Posted by vcstarter
this is not an .ini file. It is an special purpose text file
Sure looks like an INI. Regardless, why not come up with unique names?
Re: GetPrivateProfileString Reading Section With Multiple Keys
I cannot modify the file. It is given as is
Re: GetPrivateProfileString Reading Section With Multiple Keys
Then write your own parser!
It is nor difficult: read each string, search for the '=', left part (before '=') would be the key and the rest (after the '=') - the value.
Re: GetPrivateProfileString Reading Section With Multiple Keys
OK I will do so, this is basically what I am working on now