Achieve Scalability in Program
I have a file stored in some location and I want to use this file some other C program. If I give the path of the file hard coded in the program then later on if I move the file to some other location then again I have to change the path of the file in the program. But instead I want to make the program recognize the file path even if I change the file location somewhere. How to achieve the same?
Re: Achieve Scalability in Program
You can define the filename in a global variable and then use the variable in the program.If the file name changes only the global variable gets changed.This is one of the option for achieving the desired result of yours.
Re: Achieve Scalability in Program
You can declare the variable as an environment variable. (ENV variable of the ENV in which you are running the code. May be DOS, WINDOWS or UNIX). Place all the files which are read to be read by your code in this location. You can move the files to whichever location you want and just change the ENV variable to point to that location:)
Advantage of using ENV variable is, not only one package but many packages/applications can use this variable.
Re: Achieve Scalability in Program
Thanks for your input. BUt could you tell me how should I declare the variable as an environment variable.