Printing all environment variables in C / C++

后端 未结 9 1660
时光说笑
时光说笑 2020-11-27 14:23

How do I get the list of all environment variables in C and/or C++?

I know that getenv can be used to read an environment variable, but how do I list th

9条回答
  •  难免孤独
    2020-11-27 14:30

    int main(int argc, char* argv[], char* envp[]) {
       // loop through envp to get all environments as "NAME=val" until you hit NULL.
    }
    

提交回复
热议问题