Hi there. I want to read from a text file witch contains five names.
The program must display the context of the file in reverse order. Now, everything works fine as long as the names are all on the same line, e.g. Tom Boby Sarah Elena George
but if the names are in separate lines like one name per line then it only desplayes the last name(txt file attached). How do i fix this?

Thanks for your help




Code:
ifstream fp;

int main()
{
    char in_char;

    fp.open("names.txt", ios::in);

    if(!fp)
    {
    cout<<"**Error opening file**\n";
    exit(0);
    }

    fp.seekg(-1l,ios::end);

   while(fp.get(in_char))
    {
     fp.seekg(-2l,ios::cur);
     cout<<in_char;
    }
    fp.close();
    getch();
    return 0;
}