vendredi 29 juin 2018

ifstream checking read error

I found the following code for reading whole file into a string. Unfortunately, I do no know how to properly check if whole file content has been loaded. There is is_open function, however it does not provide all information. Will be grateful for any help!

std::ifstream file(fileName);
std::string content = std::string((
  std::istreambuf_iterator<char>(file)),
  std::istreambuf_iterator<char>());

Aucun commentaire:

Enregistrer un commentaire