I have a file that I have opened with std::ifstream. I have have a line of code that I want to parse:
<image source="tileset/grass-tiles-2-small.png" width="384" height="192"/>
And lets say I am interested in "384" found after width="
I am at a loss as how to best extract "384" from that line as the number 384 is not constant at all.
void parseFile(const std::string &mfName)
{
std::ifstream file(mfName);
std::string line;
if (file.is_open())
{
while (getline(file, line))
{
std::size_t found = line.find("width");
if (found != std::string::npos)
{
std::cout << found << std::endl;
}
}
}
else
std::cerr << "file failed to open" << std::endl;
}
Could anyone give me a hint or a link to a good tutorial that covers this?