I have a set of points and they are separated by a semicolon. I need to select the all points in column 2 that are greater than 0 and their corresponding column1 and column3 points. Below is my input and code. I'm unable separate columns 2 and 3. Could you kindly help me.
My input file:
500; 600; 200
100; -200; 300
200; -500; 850
420; 350; 650
My code is as below
ifstream inputFile("inputfile.txt");
string line;
float column1, column2, column3;
vector <float> column1Vector;
vector <float> column2Vector;
vector <float> column3Vector;
while (getline(inputFile, line))
{
istringstream ss(line);
ss >> column1 >> column2 >> column3;
if (column2 > 0)
{
column1Vector.push_back(column1);
column2Vector.push_back(column2);
column3Vector.push_back(column3);
}
}
inputFile.close();
My output should be as follows:
500; 600; 200
420; 350; 650
Thanks in advance.