Use the OS specific read methods or memory map the file.
Off topic for comp.lang.c++
[/QUOTE]
Not off topic as I need to do that in a c++ program.
He means that any viable answers would be off topic, not that
the question was. There's no way to do this in pure, portable
C++ that is guaranteed to work (which you probably didn't know
before asking). The problem is that once the filebuf has seen
EOF, it may (and probably does) remember this fact, and you have
no way of clearing this status. You also have no way of
reliably turning off buffering for input. (The way stream input
works, you really need at least a one character buffer anyway.)
The result is that you'll need to use some platform dependant
functions, and those are off topic here. Independantly of any
considerations of politness or respect for the groups charter,
you'll probably get faster and better answers in a platform
oriented group.