up: programming:c  
c programming
environment variables
What links here?

accessing environment variables

char * getenv(const char * name);


Alternately, environment variables may be accessed by using the special form of main():
int main(int argc, char * argv[], char *envp[]);
At startup, the variable envp Is set to point to the process's environment, which is in the form of an array of C-strings. The last element in the array is a NULL pointer indicating the end of the array. This enables you traverse the entire array easily:

//execute loop so long as envp[n] isn't NULL
for (int n=0; envp[n]; n++) {
    cout << envp[n]<< endl;
}


setting environment variables

int putenv(const char * var);
var must be of the form varname=value. This does not affect the master environment, only the copy used by the currently running program, which is then inherited by any child processes.

References:



http://www.informit.com/guides/content.aspx?g=cplusplus
programming - C - environment variables
programming - windows - win32 structures
programming - pascal - procedure - val
MC6802 - assembler - directives - opt
programming - C - findfirst and findnext
programming - C - type size_t
code vault - dbgprintf
MC6802 - assembler - directives - zmb
programming - sqlite3 - c interface - sqlite3_reset(stmt)
false positive for link search
microsoft windows xp - how to slipstream XP
filename:programming - C - environment variables
filename:programming%20%2D%20C%20%2D%20environment%20variables
last edit:February 06 2010 08:55:24 (5215 days ago)
ct = 1716077119.000000 = May 18 2024 20:05:19
ft = 1265464524.000000 = February 06 2010 08:55:24
dt = 450612595.000000