Including files into an executable at compile/link time

  • Thread starter Thread starter mezarashi
  • Start date Start date
  • Tags Tags
    files Time
AI Thread Summary
To include a large .txt data file within an executable in Visual C++ using MS Visual Studio 2005, the recommended approach is to statically initialize a character pointer with the file's content. This method allows the program to access the data without needing a separate file during distribution. While attempts to use HTML resources have been unsuccessful, directly embedding the text as a char* variable can effectively solve the issue. This approach simplifies distribution by consolidating the program and its required data into a single executable file.
mezarashi
Homework Helper
Messages
652
Reaction score
0
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.
 
Technology news on Phys.org
You should be able to make it a large statically initialized char* and stick it in your program.

e.g.

Code:
char* file = "stuff that's in the file";

- Warren
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Back
Top