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
Get the value of an environment variable
#include <stdlib.h>
char* getenv( const char* name );
- name
- The name of the environment variable whose value you want to get.
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
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.
A pointer to the value assigned to name,
or NULL if name wasn't found in the environment.
|
Don't modify the returned string. |
#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;
}
ANSI,
POSIX 1003.1
Safety: | |
Cancellation point |
No |
Interrupt handler |
No |
Signal handler |
No |
Thread |
No |
The getenv() function
manipulates the environment pointed to by the global
environ variable.
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