vendredi 29 juin 2018

Do a file containing words separated by newline and a vector of strings for those words in C++ have same size?

The file is of the following form:

word1
word2
word3
...

And I create vector of strings after reading those words from the file like this:

std::vector<string> words;
string w;
ifstream file("input");
while(getline(file,w))
    words.push_back(w);
file.close();

Will the size of physical memory occupied by the vector be same as the size of input file? Why?

Aucun commentaire:

Enregistrer un commentaire