Possible Duplicate:
Parse config file in C/C++
I have a text file in C++ that looks something like this:
[layer]
type=background
data=
1,1,1,1,1,1,11,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,11,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,11,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,11,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,11,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,11,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,11,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,11,1,1,1,1,1,1,1,1,1,1,1,1,1,
However I have multiple layers in the same text file, and each has to be built in a different way, however I need to get the values shown in "data=" for each layer.
How would I go accomplishing this? A method that I have tried is storing them to a vector, but after storing everything in a vector no sollution to extracting those values from the vector comes to my mind...
while(file >> line)
{
words.push_back(line);
}
if(find(words.begin(), words.end(), "[header]") != words.end())
{
for(int i = find(words.begin(), words.end(), "[header]"); words.at(i) != "\n"; i++)
{
word += words.at[i];
}
}
cout << word << endl;
file.close();