I have a function below which is supposed to read from a continuous updating file...by another program.
for this reason I used a fileptr int to keep track of the last known good read
so this index value is updating correctly but it is not being used by getline.
and it hangs. How can provide my fileptr index to be used to getline so it can get new lines from that index.
int ReadErrorFile()
{
string line,Strremain;
int found, NP=0xFF;
static long int fileptr=0;
string str2="node id = ";
string dummystrlength ="health:nodeid=";
char temp;
if(ErrorFile.is_open())
{
//cout<<"before seek"<<endl;
ErrorFile.seekg (fileptr, ios::beg);
//cout<<"seek end"<<endl;
while(getline(ErrorFile,line))
{
fileptr= ErrorFile.tellg();
cout<<"while loop getline"<<line<<fileptr<<endl;
found=line.find(str2);//gets position of the ID
//cout<<"after tell"<<line<<endl;
if (found!=string::npos)//if line is found get ptr store id for return
{
cout<<"FP Value ErrorFile.tellg()"<<fileptr<<endl;
cout<<line<<endl;
if(line.find('x')==string::npos) //not a hex value so can read node id value
{
//update the file ptr after every line read
stringstream str(line);
cout<<"str length"<<dummystrlength.length();
for(int i=0; i<dummystrlength.length(); i++)
{
str >> temp; //getting rid of all chars before the no
//cout<<"All chars being rid "<<temp<<endl;
}
str >> NP; //read node id
cout<<"NP read from the file"<<NP<<endl;
break;
}
}
}
}
else
{
cout<<" \n Output File is missing \n"<<endl;
}