void dataRunner::populateVector(vector <data>& dataVector) {
string temp;
data vdata;
ifstream inFile("data.csv");
//check if file is open for reading
if (inFile.is_open()) {
cout << "File Opened!" << endl;
cout << endl;
}
else{
cout << "File Could not be opened" << endl;
}
while(!inFile.eof())
{
if( getline(inFile, temp, ','))
{
vdata.setPrice(atof(temp.c_str()));
getline(inFile, temp, ',');
vdata.setCount(atoi(temp.c_str()));
getline(inFile, temp, ',');
vdata.setID(atof(temp.c_str()));
dataVector.push_back(vdata);
}
}
inFile.close();
}
How do I search through the vector to , for example, find the highest or lowest count? I have a function dataRunner::findHighestCount (vector <data>& dataVector)
I want to print out the information (ID, PRICE) associated with the highest count and print it out on the screen for the user. This is what my main function looks like: