|
|
1.1 ! root 1: ! 2: ! 3: getenv() General Function getenv() ! 4: ! 5: ! 6: ! 7: ! 8: Read environmental variable ! 9: ! 10: cchhaarr *ggeetteennvv(_V_A_R_I_A_B_L_E) cchhaarr *_V_A_R_I_A_B_L_E; ! 11: ! 12: A program may read variables from its environment. This allows ! 13: the program to accept information that is specific to it. The ! 14: environment consists of an array of strings, each having the form ! 15: VARIABLE=VALUE. When called with the string VARIABLE, getenv ! 16: reads the environment, and returns a pointer to the string VALUE. ! 17: ! 18: ***** Example ***** ! 19: ! 20: This example prints the environmental variable PATH. ! 21: ! 22: ! 23: #include <stdio.h> ! 24: ! 25: main() ! 26: { ! 27: char *env; ! 28: extern char *getenv(); ! 29: ! 30: ! 31: ! 32: if ((env = getenv("PATH")) == NULL) { ! 33: printf("Sorry, cannot find PATH\n"); ! 34: exit(1); ! 35: } ! 36: printf("PATH = %s\n", env); ! 37: } ! 38: ! 39: ! 40: ***** See Also ***** ! 41: ! 42: environmental variables, envp, exec, sh ! 43: ! 44: ***** Diagnostics ***** ! 45: ! 46: When VARIABLE is not found or has no value, getenv returns NULL. ! 47: ! 48: ! 49: ! 50: ! 51: ! 52: ! 53: ! 54: ! 55: ! 56: ! 57: ! 58: ! 59: ! 60: ! 61: ! 62: ! 63: ! 64: COHERENT Lexicon Page 1 ! 65: ! 66:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.