I used the search function but could not really find what i was searching for.
I have the following problem:
There is a file like this:
370 18 28 1 129 120
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
370 18 28 1 129 78
0 0 0 0 0 0
https://suckmypic.net/84499/data.png
I want to read the 1st, 5th and 6th integers into a 3-dimensional vector. after that i want to sort the data etc.. but i just cant read this in
Here is what i have:
#include <fstream>
#include <iostream>
int main{
//first open the file
std::fstream file;
file.open("highscore.txt", std::ios::in);
if (file.fail()){
perror("could not load highscore.txt file\n");
}
//create some stuff for temp save
std::string tmp;
int tmpNumPoints, tmpNumFired, tmpNumGot, tmpint;
//now extract the integer we need (points, shots fired, shots got)
while (std::getline(file, tmp, '\n')){
//IN-(1)STRING--POINTS--------(2)--------------(3)---------------(4)--------------(5)----Shots fired----(6)----Shots got
file >> tmpNumPoints >> tmp >> tmpint >> tmp >> tmpint >> tmp >> tmpint >> tmp >> tmpNumFired >> tmp >> tmpNumGot >> tmp;
//and store it into the integer
//------------------------X--------------Y----------Z-------
m_numInput.emplace_back(tmpNumPoints, tmpNumFired, tmpNumGot);
}
//close the file
file.close();
return 0;
}