Need Inputs for reading file from specific offset

Can you correct me where i'm going wrong.


1. Need to open existing log file.

2. make note of current end of file(ref1).

3. call_processing_routine (this results in the log file writing ).

4. now read the log file begging at ref1(earlier eof) till the current eof.

Wrote this apparently this is not working.

using namespace std;

#include <fstream>

int main () {
string STRING;
fstream infile; ("example.txt", ios::in);// | ios::nocreate);// | ios::ate );
if(!infile.is_open()) {
cout<<"error opening\n";
exit (1);
getchar(); //During this will open the example.txt and add contents
while(infile.good()) {

Last edited on
you need tellp() to get the current offset (after seekp()).
After the call of getchar() you need seekg() with the value of the previous tellp() in order to set the read pointer of the stream
Topic archived. No new replies allowed.