View Single Post
Old 05-25-2003, 09:46 PM   #1 (permalink)
Danish
Registered User
 
Join Date: Mar 2003
Posts: 12
Danish is on a distinguished road
Send a message via AIM to Danish
Binary I/O file reading (0x1a trouble)

My problem: I need to know how to read a block of n bytes from a file and copy them to a buffer in memory. I am trying to use open() and read(), and it works just fine as long as there is no 0x1a in the file. But I have them in there. Am I using the wrong function for this? I mean, getc() works, but I don't really want to use a for loop just to get the contents of a file (efficiency goes down the crapper). I'm thinking there's a flag that I could use for open that would override this, but lseek() sees past the 0x1a's for the eof. I'm really confused right now, so any help is appreciated. Thanks.

I'll post the answer, of course, if I find it.

- Dane

Edit: Okay, the problem I was having is that I was assuming getc() was the only way to get binary data. fread() does that too. I wonder if there's a way to use those lower-level functions, though? Well, either way, I'm happy.
Danish is offline   Reply With Quote