say I have a file which looks like this:
x 1
y 2
z 3
what im trying to do is looping through the file and store it inside a variable called header, when ever the header is equal to "x", "y" or "z", i want to store the numbers after it inside a variable called value like this:
string header;
string value;
ifstream readFile("filename.txt");
while (!readFile.eof()) {
readFile >> header;
if (header == "x") {
//store 1 to value
}
else if (header == "y") {
//store 2 to value
}
else if (header == "z") {
// store 3 to value
}
}
can someone help me please as i cant figure out a way to achieve it