Hi,
I am trying to move the file pointer back to the original location,
but not able to using seekg, can someone help ?
Thanks,
Kapil
I am trying to move the file pointer back to the original location,
but not able to using seekg, can someone help ?
Thanks,
Kapil
Code:
#include "stdafx.h"
using std::cerr;
using std::endl;
using std::ios;
#include <iostream>
#include <fstream>
using std::ifstream;
using std::string;
#include <sstream>
#include <map>
using std::map;
using std::multimap;
using std::cout;
using std::pair;
int main ( )
{
ifstream file_read("data.txt",ios::in);
if(!file_read)
{
cerr << "File could not be opened\n" << endl;
exit(1);
}
file_read.seekg(0);
string inputString;
cout << "File pointer is at " << file_read.tellg();
while (file_read >> inputString)
{
}
file_read.seekg(0);
// Why seekg fails !!!
cout << "File pointer is at " << file_read.tellg();
}
Comment