#include <fstream>
#include <sstream>
#include <iostream>

void print_backwards(std::istream& in)
{
    char ch;
    if (!in.get(ch))                        // base condition: Nothing more to be extracted from stream.
        return;

    print_backwards(in);                    // extract more input and print it prior to
    std::cout << ch;                        // printing this character.
}

int main()
{
    // our makeshift file contents.  Replace with std::ifstream in("filename")
    std::istringstream in(
        "Jack and Jill went up the hill\n"
        "To fetch a pail of water\n"
        "Jack fell down and broke his crown\n"
        "And Jill came tumbling after"
    );

    print_backwards(in);
}

