Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) std::fstream

 

std::fstream is an STL stream for file I/O.

 

#include <fstream>

int main()
{
  {
    //Create a new file (or remove its contents)
    std::ofstream f;
    f.open("my_file.txt");
    f << "Hello";
  }
  {
    //Append to file
    std::ofstream f;
    f.open("my_file.txt",std::ios::app);
    f << " world\n";
  }
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict