getenv()
Get the value of an environment variable
Synopsis:
#include <stdlib.h>
char* getenv( const char* name );
Arguments:
- name
- The name of the environment variable whose value you want to get.
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The getenv() function searches the environment list for a string in the form name=value and returns a pointer to a string containing the value for the specified name. The matching is case-sensitive.
Returns:
A pointer to the value assigned to name, or NULL if name wasn't found in the environment.
Don't modify the returned string.
Examples:
#include <stdio.h> #include <stdlib.h> int main( void ) { char* path; path = getenv( "INCLUDE" ); if( path != NULL ) { printf( "INCLUDE=%s\n", path ); return EXIT_SUCCESS; } return EXIT_FAILURE; }
Classification:
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | No |
Thread | No |
Caveats:
The getenv() function manipulates the environment pointed to by the global environ variable.