Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   sun string comparison (http://www.go4expert.com/forums/sun-string-comparison-t24062/)

heidik 2Dec2010 16:39

sun string comparison
 
Hello everyone.

I am reading strings from file and I have to identify strings that are similar to eachother but on the basis of a substring i-e if a substring of the two/more strings match then the two/more strings would be considered similar.

Code:

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);
}*/



All times are GMT +5.5. The time now is 21:35.