Line 20: Don't loop on
eof(). Loop on
good() instead. You can combine lines 20 and 22 to do that:
while (getline (in, ybbys))
Line 26: This loop will never execute, since you have already read to EOF using the loop starting at line 20.
Line 23: You cannot assign to an array like that. You would have to use
strcpy(). That said, why are you using a char array anyway? You don't need it. The
string class will tell you the length of your string.
What exactly are you trying to do? Only keep lines with (2 < length < 8)? Reconsider how your loops work.
I think that if you were to delete lines 25, 26, and 27 you might be much closer to what you want.
Also, be careful to use indentation consistently:
1 2 3 4 5 6
|
string line;
while (getline (in, line))
{
if ((line.length() < 8) && (line.length() > 2))
out << line << endl;
}
|
Hope this helps.