tags:

views:

71

answers:

1

Hi, first question here!

I'm writing a grep type program for Windows, just for fun (using Mingw). It works well for text files where lines are terminated by '\n'. I'm using fstream::getline() for this.

But I also need to be able to search files containing just a giant block of text with no line numbers. fstream::getline() fails here. Is there any function to read N characters into a buffer from such a file?

Also, what's the best way to tell the user where the match was found in such a file?

+2  A: 

istream::read() will read an arbitrary number of characters from an istream.

As for where in the file it was found, a line number and character offset might be a good way to go.

luke
This answers my question! Issue resolved I guess..
Quicksilver