#include <fstream> 
#include <iostream>
#include <string>
using namespace std;
//#define WRITE

main()
{
   #ifdef WRITE
    cout<<"Writing in file .... "<<endl;    
    string str = "Time is a great teacher, but unfortunately "
                 "it kills all its pupils. Berlioz";
    ofstream outfile("TEST.TXT"); 
    for(int j=0; j<str.size(); j++) 
       outfile.put( str[j] ); 
    cout << "File written\n";
    outfile.close();
   #else 
    cout<<"Reading from file ...."<<endl; 
    char ch; //character to read
    ifstream infile("TEST.TXT"); //create file for input
    /*while( infile ) //read until EOF or error
    {
       infile.get(ch); //read character
       cout << ch; //display it
    }*/
    cout<<infile.rdbuf();
    cout << endl;
   #endif  
    
    system("pause");
}
