While loops Issue

C++ Guru's

Can you please assist me in the following below why it is failing. This code is suppose to read from two files. It reads the first line from the ifspeed document then its suppose to go to the other document ifsbtl and read all the lines in that document then after it is finished go to the next line in ifspeed. Any thoughts??

while( getline(ifspeed,sline) ) {

while(getline(ifsbtl,bline)) {

if condition to compare line in other document

}

}
but why do you require this .. means i am not able to understand the requirement
so i can compare data in two files
memcmp
memcmp over 11500 lines? i just wanted to why it failed the way i have up there?
If you want to compare corresponding lines in the two files:

1
2
3
4
while ( getline(ifspeed, sline) ) && getline(ifsbtl, bline) )
{
    // comparison here.
}


Otherwise you're just comparing one line of ifspeed to every line of ifsbtl, which seems rather nonsensical.
cire i am comparing two diffrent documents. they are not the same. hence i need to read one line from ifspeed and compare that all the lines in ifsbtl then move to another line 2...3...4...etc in ifspeed and compare again with all lines in ifsbtl.
To what end? (And that's not what you're doing.)
Last edited on
In that case you have to start reading from the beginning of ifsbtl again.

1
2
3
4
5
6
7
8
while( getline(ifspeed,sline) ) {
	while(getline(ifsbtl,bline)) {
		if condition to compare line in other document

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