Answers for "close a filestream c++"

C++
0

close a filestream c++

// fstream::open / fstream::close
#include <fstream>      // std::fstream

int main () {

  // instantiating the file stream
  std::fstream fs;
  
  // opening the file with the fstream
  fs.open ("test.txt", std::fstream::in | std::fstream::out | std::fstream::app);

  fs << " more lorem ipsum";

  // closing the file
  fs.close();

  return 0;
}
Posted by: Guest on September-24-2021

Browse Popular Code Answers by Language