0

I have files formatted as so:

2   3
9   7   11
12  5   6
3   4

they always start with 2 integers and end with 2 integers outside of that it may vary. I need to treat the final two ints differently then the integers before them. Roughly what I want to do is:

    size_t c1;
    myfile >> c1;
    while (!myfile.eof()){
        //do stuff to c1;
        myfile >> c1;
        myfile >> c2;

        if (!myfile.eof()) // put c2 back    <---- how do I do this?

    }
    myfile.close();
  • Did you try [`tellg`](http://en.cppreference.com/w/cpp/io/basic_istream/tellg) and [`seekg`](http://en.cppreference.com/w/cpp/io/basic_istream/seekg)? Also see [Why is iostream::eof inside a loop condition considered wrong](http://stackoverflow.com/questions/5605125/why-is-iostreameof-inside-a-loop-condition-considered-wrong) – Captain Obvlious Nov 13 '14 at 13:32
  • This is a bit unclear for me. What exactly do you want to do with the two last ones? I would simply read all of the integers into ``std::vector`` and then do whatever I like with the last ones. If that's not the case, there are methods mentioned by @CaptainObvlious – macfij Nov 13 '14 at 13:40
  • Captain Obvious' solution works, but I feel like an idiot, of course I should of loaded them into a vector. – Damien King-Acevedo Nov 13 '14 at 13:45

0 Answers0