What's the use of the third, environment variable argument to the C++ main()?

前端 未结 4 444
误落风尘
误落风尘 2020-12-17 03:40

I have come to understand that char **envp is the third argument to main, and with the help of the code below, I was able to see what it actually c

4条回答
  •  春和景丽
    2020-12-17 04:36

    env allows you to access the environment variables. It contains an array of strings. Examples are the users home directory, the configured language scheme, the PATH variable (where to look for directly executable programs?), ...

    You can also set individual environment variables. For example, if you have testing (learning) and also a production system you deploy your application to. On one system you could set the variable "MY_APP_MODE=TEST" and on the other system you could specify "MY_APP_MODE=PROD". So you don't need to deploy different applications to the test and production systems. Your application could determine itself in what environment it is run.

提交回复
热议问题