Lets say I have an outer while loop to read each character and output it to console. I also want to flag a word if it is found and by using the peek method I can find the first instance of a word. Is there a way to peek multiple places ahead. For example, if I looking for the word "payday" . I know I can input this into a string and search a string, but I want to read files in binary mode and I don't want to take away any values from the outer loop. If I have an inner loop with a read method, those values are not then displayed via the outer loop.
Thanks
int main()
ifstream strm;
char *chr = new char;
strm.open("mytext.txt",ios::out | ios::binary);
while (strm.read(chr,1)
{
if (strm.peek() == 'p';
{
cout << "found a word beginning with 'p'" << endl;
//what if I want to read multiple characters ahead. Peek will read only one.
}
}