The simple way is to just compile the whole code, then have some kind of decision in the code, like this.
int main ( ) {
if ( something ) {
program1();
} else {
program2();
}
}
A more complicated way would be to write each separate module as a DLL, then at run-time you can choose which library instance to access.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
What do you mean by "include a file"?
Are you talking about source code?
Or binary data (pictures, music, etc.)?
Or just regular text (ASCII, RTF, etc.)?
How do you want it to be used at runtime? And what difference does it make whether you include one or the other?
Answer these three and we'll have an easier time answering you...
Hope this helps.
Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
If you want to pass the name of the file to your program at runtime then just add the filename on the command line when you run your program.
c:\myprog.exe file1.txt <Enter>
Then your program can use the arguments to main() to get the filename
int main(int argc, char* argv[])
{
char* filename = 0;
if( argc > 1)
filename = argv[1];
}
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
I think it would help everyone to understand if you would provide some examples. Do you need functions to display information in different languages, such as English, German, French etc.? You create a language DLL for each language you want to support then install the desired language dll when you install the rest of the program. I'm certain you must have seen this before when you try to install something that other people have written.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
Use DLLs like AD suggested. Instead of supplying a language it should supply an AI. The functions will be the same for each AI DLL, so the only variable will be the name of the DLL opened with LoadLibrary().
Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229