I am using this code for simply reading from a text file but i want to put file pointer at the begining again when it reaches to the end of file.
But my code below is not working.
u can ignore extra bits of my code... like header files... :)
#include<iostream>
#include<cstdio>
#include<cstdio>
#include<cstring>
#include<fstream>
#include <string>
using namespace std;
int main(){
char Word[20];
ifstream file;
string a;
file.open("b.txt");
while (!(file.eof())){ // run whole dic
file >> Word; // for each word
cout << "Word Read: " << Word << endl;
cout << "Pointer at: " << file.tellg() << endl << endl;
if(file.tellg()==-1){
file.seekg(0,ios::beg);
cout << "File Pointer Now at: "<< file.tellg() << endl;
cin >> a;
}
}
return 0;
}