samedi 4 avril 2015

cout incorrectly prints out the Vector of strings

The below code snippet is printing the first letter of the words rather than the entire words. But when I debug it, I see the data array containing the whole words. Can anyone explain why.



vector<string> data;
vector.resize(x);
for(int i=0; i<x; i++)
{
infile.getline(&data[i][0],32,'\n');
cout<<data[i];
if(infile.fail()) break;
}

Aucun commentaire:

Enregistrer un commentaire