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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Reading Binary files

Reading Binary files

Scheduled Pinned Locked Moved C / C++ / MFC
htmlhelptutorial
2 Posts 2 Posters 1 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.
  • B Offline
    B Offline
    BoudewijnEctor
    wrote on last edited by
    #1

    Hi, I need to build an app to open some kind of file (it kan be any kind: .exe .html .txt .hex --> really everything) as a binary (or hexadecimal file), after that I need to convert this file to a hexadecimal file with checksums. I know how to do the last thing, but I could use some help in opening files as binaries!

    R 1 Reply Last reply
    0
    • B BoudewijnEctor

      Hi, I need to build an app to open some kind of file (it kan be any kind: .exe .html .txt .hex --> really everything) as a binary (or hexadecimal file), after that I need to convert this file to a hexadecimal file with checksums. I know how to do the last thing, but I could use some help in opening files as binaries!

      R Offline
      R Offline
      RChin
      wrote on last edited by
      #2

      If you are using MFC:

      //Open a binary file called: "somefile.ext"
      CFile MyFile;         // file variable
      unsigned char nByte;  // binary buffer
      
      if( MyFile.Open(TEXT("somefile.txt"), CFile::modeRead | CFile::shareDenyNone | CFile::typeBinary) )
      {
        // read data and print to output
        while(MyFile.Read(&nByte,1))
          std::cout<
      
      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