Back to slide -- Keyboard shortcut: 'u'                      io/fstream-prog.cc - Opening, working on, and closing a file - as simple as possible.Lecture 3 - slide 18 : 27
Program 1

// Simple file program - fstream illustration - adapted from www.cplusplus.com

#include <fstream>      // std::fstream

int main () {

  std::fstream fs{"test.txt", std::fstream::out};

  // IO operations here
  fs << "Some text, and a number: " << 5 << std::endl;

  fs.close();

  return 0;
}