>Is there a function that seeks out words in a text file?
grep...but that won't help you much. getline is the way to go:
Code:
#include <string>
string find;
string line;
getline ( cin, find );
while ( getline ( fin, line ) && find != line )
;
// At this point you're right after the line you were looking for in fin
// Or you're at EOF :), so let's add this:
if ( !fin.eof() ) {
// Do your thing
}
Using C strings:
Code:
#include <string.h>
char find[SIZE]; // You define SIZE to something sane
char line[SIZE];
cin.getline ( find, sizeof find );
while ( cin.getline ( line, sizeof line ) && strcmp ( find, line ) != 0 )
;
if ( !fin.eof() ) {
// Do your thing
}