File handling

Reading from or writing to files is a common task. C++ provides robust file handling through its standard library.


  #include 
  ofstream file("example.txt");
  file << "Hello, file!";
  file.close();
  

Beginner's Guide to C++