Text file in program
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?
I don''t think so. Well, not *as* text. If you really really wanted to, you could hardcode it
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!}
--{You fight like a dairy farmer!}
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]
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]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement