dimanche 29 octobre 2017

reading from an already open if stream object

I have a text data that is three lines only

100,200,300,400, John
300,400,500,100, Abraham
600,500,500,200 , David

I want to go and read this line by line and save it in a map

This is my code and i can not get the correct output..

 void save_details ( map < vector<int> , string >m , ifstream dets ) {

     int a , b , c , d;
     string s;
     while ( dets >> a >> a >> c >> a >> s) {

         vector<int>mine.push_back(a);
         vector<int>mine.push_back(b);
         vector<int>mine.push_back(c);
         vector<int>mine.push_back(c);

         m.insert(pair<vector<int> , string>(mine , s));
     }
  }

How will i correctly and efficiently store those data in a map

Aucun commentaire:

Enregistrer un commentaire