Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/g/getenv.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/g/getenv.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/g/getenv.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/g/getenv.html on line 8

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.


Note: 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:

ANSI, POSIX 1003.1

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.

See also:

clearenv(), environ, execl(), execle(), execlp(), execlpe(), execv(), execve(), execvp(), execvpe(), putenv(), searchenv(), setenv(), spawn*() functions, system()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/g/getenv.html on line 162

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/g/getenv.html on line 162