Environment Variables
basic concept:
Generally it refers to a number of parameters used to specify the operating system in the operating environment of the operating system
When we use the dynamic link library success when, in fact, related environmental variables help the compiler to find.
Environment variables typically have a particular purpose, as well as having a generally overall system in which
Common environment variables:
PATH: Search path specified command
HOME: Specifies the user's home working directory (that is, when a user logs on to a Linux system, the default directory)
SHELL: Current Shell, its normal value / bin / bash
Environment variables related commands:
echo $ NAME (NAME environment variable refers to your name): Print an environment variable
env: View environment variables
set: View environment variables
unset: Delete the environment variable
whereis NAME: Find directory exists variables
When the input on the command line to write a name of a program, the system will prompt can not find the file, if we want to write their own programs like ls and so has the same effect, so this time we have two ways to achieve their goals , the first path is to write their own programs and also put ls like to go, and the second is to change the values of environment variables.
Environment variables generally have a global, Here are some environment variables in your code:
The same also can be obtained using environ environment variable, pay attention to things, when you need to use environ statement, preceded by extern, so the effect is the same
Use function to get: getenv () - Gets a specified environment variable
If the resulting define your own variables with this function is a local variable, but also export to convert to declare a local variable as environment variable