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. using fstream to read resource data c++

using fstream to read resource data c++

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestionlearning
3 Posts 2 Posters 0 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
    bimgot
    wrote on last edited by
    #1

    my application currently reads and uses data from files at a location on the host machine using fstream what i would like to do is include these files and their data as resources so that the application does not rely on the data being stored on the host machine i am using FindResource, LoadResource, LockResource etc but i'm having trouble passing the actual data content straight to fstream - is this possible?? FindResource(..); LoadResource(..); char* ptr = (char*) LockResource(..); fstream.open(ptr,ofstream::binary); any help would be greatly appreciated - i'm pretty new to resources!

    D 1 Reply Last reply
    0
    • B bimgot

      my application currently reads and uses data from files at a location on the host machine using fstream what i would like to do is include these files and their data as resources so that the application does not rely on the data being stored on the host machine i am using FindResource, LoadResource, LockResource etc but i'm having trouble passing the actual data content straight to fstream - is this possible?? FindResource(..); LoadResource(..); char* ptr = (char*) LockResource(..); fstream.open(ptr,ofstream::binary); any help would be greatly appreciated - i'm pretty new to resources!

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      bimgot wrote:

      char* ptr = (char*) LockResource(..);

      What do you want to do with ptr at this point?

      bimgot wrote:

      fstream.open(ptr,ofstream::binary);

      The first argument to fstream's constructor is the name of the file to open, not the actual data within the file. Perhaps that is where your confusion lies.


      "A good athlete is the result of a good and worthy opponent." - David Crow

      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

      B 1 Reply Last reply
      0
      • D David Crow

        bimgot wrote:

        char* ptr = (char*) LockResource(..);

        What do you want to do with ptr at this point?

        bimgot wrote:

        fstream.open(ptr,ofstream::binary);

        The first argument to fstream's constructor is the name of the file to open, not the actual data within the file. Perhaps that is where your confusion lies.


        "A good athlete is the result of a good and worthy opponent." - David Crow

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        B Offline
        B Offline
        bimgot
        wrote on last edited by
        #3

        as i understand LockResource returns a pointer to the first byte of the data stored in the resource.. currently i use fstream to read, validate and store some wave file data so that it can be used to play back the wave file since the open function of fstream takes a char* for the name of the file to open, i wondered if a char* for the resource would work in the same way i think my confusion is as you say with fstream but since the class i want to use the data from the resource with is based on fstream, i wondered if there was a solution that doesnt involve re-writing the class..

        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