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" }
2.1m questions
2.1m answers
60 comments
57.0k users