// -------------------
// FileInputOutput.c++
// -------------------

/*
% g++ -ansi -pedantic -Wall FileInputOutput.c++ -o FileInputOutput.app
% FileInputOutput.app FileInputOutput.c++
*/

#include <cassert>  // assert
#include <fstream>  // ifstream
#include <iostream> // cout, endl, ios_base, noskipws

int main (int argc, char* argv[]) {
    using namespace std;
    cout << "FileInputOutput.c++" << endl;

    ios_base::sync_with_stdio(false); // turn off synchronization with C I/O

    cout << "debug" << argv[1] << endl;

    {
    ifstream in(argv[1]);
    assert(in);
    in >> noskipws;

    char c;
    while (in >> c)
        cout << c;
    cout << endl;

    in.clear();
    assert(in);
    in.seekg(0);

    while (in >> c)
        cout << c;
    }

    {
    ifstream in(argv[1]);
    assert(in);
    in >> noskipws;

    char c;
    while (in >> c)
        cout << c;
    cout << endl;
    }

    cout << "Done." << endl;
    return 0;}


syntax highlighted by Code2HTML, v. 0.9.1