Saturday, February 27, 2010

C/C++ Programming under Linux - Part 3

The following program will spit the environment variables inherited when invoked.

///////////////////////////////////
// envspitter.cpp
//
// A C/C++ program to spit the environmental variables
//
// g++ -oenvspitter.exe envspitter.cpp
//

#include <stdio.h>

int main( int argc , char **argv , char **envp )
{

char **temp = envp;

while (*(temp+1) != 0 ) {
puts(*temp);
temp++;
}

return 0;

}

0 comments: