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

后端 未结 3 1654
逝去的感伤
逝去的感伤 2020-12-17 22:57

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:38

    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");
    

提交回复
热议问题