two while loop problem

Hello everybody,

I have two big text files and i want to compare 6. line of first file to 53. line of second file. The problem is when i compare their lines(6. and 53.), my program compares only first 6. line of the first file to 53.lines of second file. I use two while loop. inner while loop goes to the end but outer while loop only one time. What have i to do?

void main()
{

int i,j,loop,loopTPX,loopCAEN,f,m;;
double timeTPX, timeCAEN,time12;

string word;
string word1;
string word2;
string word3;
string word4;

ifstream inCAEN("testPu238Tpxclock0.1acqt0.1CAEN.txt");
ifstream inTPX1 ("testPu238Tpxclock0.1acqt0.1.txt");
ifstream inTPX2("testPu238Tpxclock0.1acqt0.1.txt.dsc");

loopTPX=0;
loopCAEN=0;

while(inCAEN!=NULL){

for(loop=0;loop<4096+7;loop++){
getline(inCAEN,word);

if(loop==5){
if(word.length()>19)
word1=word.substr(19,19);
timeCAEN=atof(word1.c_str());
loopCAEN++;
}
}

while(inTPX2!=NULL){
for(m=0;m<63;m++) {
getline(inTPX2,word4);
if(m==53) {
timeTPX=atof(word4.c_str());
printf("%d %d %f %f\n",loopCAEN, loopTPX,timeTPX,timeCAEN);
loopTPX++;

}
}
}
}

inTPX2.close();
inCAEN.close();

getch();
I'm not sure if I quite understand the question:
Gadir wrote:
i want to compare 6. line of first file to 53. line of second file.

then
Gadir wrote:
my program compares only first 6. line of the first file to 53.lines of second file


I know English is probably not your first language, but the expected behavior and observed behavior seem identical to me.
i have solved this problem with the help

after second loop i had to write

inTPX2.clear();
inTPX2.seekg(0, ios::beg);
Topic archived. No new replies allowed.