Problem with opening binary files using open() 
Author Message
 Problem with opening binary files using open()

Hi,

I'm using the function open() in a DOS program in the
following way:  

    int fp;
    fp=open(Filename,O_BINARY | O_RDONLY);

What I need to do is to open the binary files in the same
way as text files, just like the DOS editor does. The above
statement opens text files just fine, but reads garbage from
any binary files (using read()). Any suggestions?



Tue, 16 Mar 1999 03:00:00 GMT  
 Problem with opening binary files using open()


B.) wrote in comp.lang.c:

=>Hi,

=>I'm using the function open() in a DOS program in the
=>following way:  
=>
=>    int fp;
=>    fp=open(Filename,O_BINARY | O_RDONLY);

=>What I need to do is to open the binary files in the same
=>way as text files, just like the DOS editor does. The above
=>statement opens text files just fine, but reads garbage from
=>any binary files (using read()). Any suggestions?

open() is not ISO C and is implementation specific. Use fopen(). Then
use fread(). open() under MSVC does not offer any significant
advantage over using real C.

<><><><><><><><><><><><><><><><><><><><>

Wizard's First Rule:
    People are stupid.
            - Terry Goodkind

<><><><><><><><><><><><><><><><><><><><>



Wed, 17 Mar 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. opening a file using open method

2. Problem opening a file for read while it is open for write

3. CEditView problem: opening a file that is still open

4. can't open file: to many files open

5. Difference between MRU File Open and Regular File Open

6. Open BINARY file in the IDE?

7. Cannot continue opening Binary Files

8. Opening a file in text or binary format?

9. need sample code for: opening and editing hexidecimal values in a binary file

10. Truncating a binary file opened for read and write

11. Opening a binary file

12. Open a binary file as a resource with resource ID

 

 
Powered by phpBB® Forum Software