i have a txt file which have some lines ...and my code is :
string line;
ifstream myfile("c:\\main.txt");
bool passport = true;
while(passport==true){
int pos1=0;
cout<<setw(20)<<"PassPort_Number : ";
cin>>add.Id ;
if (myfile.is_open())
{
while(!myfile.eof()){
getline(myfile,line);
pos1+=line.find(add.Id);
cout<<pos1;
}
}
if(pos1<0)
passport=false;
else {
cout<<"PassPort Number tekrariye :d"<<endl;
}
}
first time everything is ok but at the second time of running it doesn't enter to second while (while(!myfile.eof() ) ... what's wrong with my code?
when it goes to the end of text file it doesn't back to the first of file at the next loop ... how can i back to the first of text file ?