Jump to content
  • Advertisement

Archived

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

LordN

Text file in program

This topic is 5446 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
Why not just do a check on whether the text file exist? If it doesn''t then just bail out with an error





--{You fight like a dairy farmer!}

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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!