|
-
Jul 10th, 2003, 09:27 PM
#1
Thread Starter
Hyperactive Member
ofstream: checking size of associated file <resolved>
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
Last edited by Comreak; Jul 13th, 2003 at 02:25 PM.
-
Jul 11th, 2003, 05:21 AM
#2
Monday Morning Lunatic
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.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jul 11th, 2003, 08:12 PM
#3
Thread Starter
Hyperactive Member
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.
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()?
-
Jul 13th, 2003, 07:58 AM
#4
Monday Morning Lunatic
Read the documentation, MS even have a sample program on MSDN.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|