How can I peak at the data inside an ofstream object when it's associated with a file? I want to do this so I can make sure that the data inside a file can be stored inside a buffer (char string) safely. Thanks.
EDIT:// brevity
Printable View
How can I peak at the data inside an ofstream object when it's associated with a file? I want to do this so I can make sure that the data inside a file can be stored inside a buffer (char string) safely. Thanks.
EDIT:// brevity
Keep reading it into blocks of a fixed size (say 8K), eventually you'll read less than your buffer size, and you know you've hit the end.
Alternatively, use stat() on the file before you open it to find out its size.
Stat() sounds like a good way to do what I want to do. I'm a bit confused though; how would someone go about using stat()?Quote:
Originally posted by parksie
Keep reading it into blocks of a fixed size (say 8K), eventually you'll read less than your buffer size, and you know you've hit the end.
Alternatively, use stat() on the file before you open it to find out its size.
Read the documentation, MS even have a sample program on MSDN.