topical media & game development

talk show tell print

professional-program-25-FileWrite-FileWrite.c

? / professional-program-25-FileWrite-FileWrite.c


  
FileWrite.cpp

  
  include <iostream>
  include <fstream>
  
  using namespace std;
  
  int main()
  {
    ofstream outFile("FileWrite.out");
  
    if (outFile.fail()) {
      cerr << "Unable to open file for writing." << endl;
      exit(1);
    }
  
    outFile << "Hello!" << endl;
  
    outFile.close();
  
    ofstream appendFile("FileWrite.out", ios_base::app);
  
    if (appendFile.fail()) {
      cerr << "Unable to open file for writing." << endl;
      exit(1);
    }
  
    appendFile << "Append!" << endl;
  
    appendFile.close();
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.