I have deleted the vector in my code. Sorry I missed it here :P
and finally trying to find duplicatesCode:if (pos1 != string::npos) { istringstream ss(line); getline(ss,ordb.lineID,','); getline(ss,ordb.dateTime,','); getline(ss,ordb.remSTr); dupOrdTime.push_back(ordb); // I am populating the vector here continue; }
Code:for(std::vector<ordRecvblock>::iterator i = dupOrdTime.begin(); i != dupOrdTime.end(); i = ret.second) { std::vector<ordRecvblock>* dupVec = new std::vector<ordRecvblock>; // stores values that were duplicated ret = std::equal_range(i, dupOrdTime.end(), *i); for(std::vector<ordRecvblock>::iterator j = ret.first; j != ret.second; ++j) { dupVec->push_back(*j); } for(std::vector<ordRecvblock>::iterator i = dupVec.begin(); i != dupVec.end(); ++i) { cout << i->lineID << ',' << i->dateTime << ',' << i->remSTr << endl; // printing the duplicates } }




Reply With Quote