1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Including files into an executable at compile/link time

  1. Apr 19, 2007 #1

    mezarashi

    User Avatar
    Homework Helper

    I have a program that opens a very large .txt data file. This data file remains unchanged, but is always required to run the program. What I want to do is include this .txt into the .exe so that when I distribute the program I don't need to distribute two files, but only one instead.

    I'm using Visual C++ with MS Visual Studio 2005. I've played around with some of the resources, but to no avail. I tried adding it as an HTML resource and then loading the resource, but the pointer to this resource apparently is invalid whether I treat it as a string of character bytes or as a file pointer.

    Any ideas? Thanks in advance.
     
  2. jcsd
  3. Apr 19, 2007 #2

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    You should be able to make it a large statically initialized char* and stick it in your program.

    e.g.

    Code (Text):

    char* file = "stuff that's in the file";
     
    - Warren
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Including files into an executable at compile/link time
Loading...