file reading

hi all, question here about how to most efficiently do some file reading.

I have a txt file, and must read through the data until i hit
a certain word (we'll call it "word" in this case)

so file would look something like this

datadatadata
datadatadata
datadatadata
word
datadatadata
datadatadata

i was doing

while (infile != "word")
{
do task
}

but that didn't work.

Thanks for any advice
try:
1
2
3
4
5
6
while( infile.good() )
{
      infile >> string_to_read;
      if ( string_to_read == "word" ) continue
      // do task
}
got it all worked out. thanks for the help man
Topic archived. No new replies allowed.