Archived

This topic is now archived and is closed to further replies.

LordN

Text file in program

Recommended Posts

I have a program which loads in a text file. In order to run correctly, the text file has to be in the same folder as the executable. Is there any way to compile the program so that the text file is in the executable itself?

Share this post


Link to post
Share on other sites
You could write a small program to convert the text file to a .c or .cpp file.

Step 1: replace all the carriage returns in the file with '\n'
Step 2: put backslashes in front of quote marks
Step 3: put this:

char THE_WHOLE_FILE[] = "

before the beginning of the file
Step 4: put this:

";

at the end of the file.
Step 5: save it as a .c file.

And voila!

[edited by - andy_fish on July 28, 2003 3:33:56 AM]

Share this post


Link to post
Share on other sites