View Single Post
Old 05-26-2003, 10:02 AM   #3 (permalink)
Danish
Registered User
 
Join Date: Mar 2003
Posts: 12
Danish is on a distinguished road
Send a message via AIM to Danish
Oh, thank you very much. I'll try this right away and see what happens. I guess I was just having problems understanding how to use read()...

Edit the first: It's still stopping after 0x1a; it detects that as EOF... I'm using MinGW, does that make a difference?

Edit the second: I tried your code, and made a file in.txt; I put in some text, and it read it fine. I opened up a hex editor, changed the fourth character to 0x1a, and it won't see past three characters. I'm still thinking this is a MinGW issue...?

Edit the third: AHA! Eureka. Change

Code:
fd = open("in.txt", O_RDONLY);
to
Code:
fd = open("in.txt", O_RDONLY | O_BINARY);
Just as I thought -- a flag in open()... well, thanks for the help.

And yeah, read() is faster than fread() afaict.
Danish is offline   Reply With Quote