/% Simple example of writing text to a file, by
  using append or standard out. %/
 

#include <iostream>
#include <fstream.h>

/* for append type = 1
   for normal out type = 0 */

#define type 0

int main() {
	char outLine[50];

	ofstream outFile;
	/* open the file */
	if(type)
		outFile.open("output.txt", ios::app);
	else
		outFile.open("output.txt", ios::out);

	/* if opening didn't fail */
	if(!outFile.fail()) {
		cout << "Enter some text: ";
		cin >> outLine;

		/* write the text to the file */
		outFile << outLine << endl;
		outFile.close();
	} else 
		cout << "Error Opening File.";

	return 0;
}
