1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
istringstream ss(line);
getline(ss,ordb.lineID,',');
getline(ss,ordb.dateTime,',');
getline(ss,ordb.remSTr);
// Check if the "lineID + remSTr" combination is already in the vector.
// If it is, compare dates and use the lesser one
// how do I compare a substring here? the substring for comparison consists of lineID and remSTr. If lineID and remSTr are similar then the two/more strings would be similar.
vector<ordRecvblock>::iterator it = find(OrdTime.begin(),OrdTime.end(),ordb);
if (it != OrdTime.end())
{
if (ordb.dateTime < it->dateTime)
{
cout << it->lineID << ',' << it->dateTime << ',' << it->remSTr << endl;
*it = ordb;
}
else
{
cout << ordb.lineID << ',' << ordb.dateTime << ',' << ordb.remSTr << endl;
}
}
/*else
{
OrdTime.push_back(ordb);
}*/
|