Results 1 to 3 of 3

Thread: Open a file in binary mode

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Sweden
    Posts
    115

    Open a file in binary mode

    How do I open a file in binary mode in C++ (using Borland C++ Builder 5)?
    What I need to do is to erase the ID3-tag of an mp3, and in VB you opened it in binary mode and wrote nothing to the 127 first bytes or something like that. I was thinking I could do that again, but in C++ instead. Any ideas how?

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    In BCB there's probably a class somewhere to do it, but here's the method a REAL programmer might use
    Code:
    #include <stdio.h>
    #include <io.h>
    #include <fcntl.h>
    
    // ...inside some function somewhere...
    int fd = _open("thefile.ext", _O_BINARY | _O_RANDOM | _O_RDWR | _O_APPEND, _S_IREAD | _S_IWRITE);
    Look up _open, _close, _read, _write in MSDN for more details on their exact parameters
    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

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Sweden
    Posts
    115

    Thumbs up

    Thanks parksie, it worked great!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width