How to list all environment variables in a c/c++ app

后端 未结 3 1396
独厮守ぢ
独厮守ぢ 2020-12-17 23:00

I know that when programming in c++ I can access individual environment variables with getenv.

I also know that, in the os x terminal, I can list ALL of the current

3条回答
  •  攒了一身酷
    2020-12-17 23:41

    Whoops, I forgot that system lets you execute terminal commands.

    This snippet gives me what I need:

    std::cout << "List of environment variables: << std::endl;
    system("env");
    

提交回复
热议问题