How to print the environment variables in a C program using "environ".
extern char **environ
#include <unistd.h> #include <stdio.h> extern char **environ; //... int i = 0; while(environ[i]) { printf("%s ", environ[i++]); // prints in form of "variable=value" }
1.4m articles
1.4m replys
5 comments
57.0k users