Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to read a specified amount bytes from a binary-file with a offset (C++)

How to read a specified amount bytes from a binary-file with a offset (C++)

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialc++
3 Posts 3 Posters 21 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    P Mehroof Abid
    wrote on last edited by
    #1

    And also by binary-file I mean the files with the weird characters and all. Next, Here is a example of what it should look like:

    read_4_bytes("file", 0); // filename, offset and end.

    Not much else to say...

    Mircea NeacsuM 1 Reply Last reply
    0
    • P P Mehroof Abid

      And also by binary-file I mean the files with the weird characters and all. Next, Here is a example of what it should look like:

      read_4_bytes("file", 0); // filename, offset and end.

      Not much else to say...

      Mircea NeacsuM Offline
      Mircea NeacsuM Offline
      Mircea Neacsu
      wrote on last edited by
      #2

      1. Use fopen function to open the file 2. Use fseek function to go to specific offset 3. Use fread function to read the 4 bytes 4. Use fclose function to close the file

      Mircea

      D 1 Reply Last reply
      0
      • Mircea NeacsuM Mircea Neacsu

        1. Use fopen function to open the file 2. Use fseek function to go to specific offset 3. Use fread function to read the 4 bytes 4. Use fclose function to close the file

        Mircea

        D Offline
        D Offline
        Daniel Pfeffer
        wrote on last edited by
        #3

        One more detail - on Windows, you must open the file in "binary" mode using the O_BINARY flag (for open) or "rb" (for fopen).

        Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups