1.GETENV (Get environment variable content)
Related functions:
Putenv,setenv,unsetenv
Table header file:
#include <stdlib.h>
To define a function:
char * getenv (const char *name);
Function Description:
Getenv () is used to get the contents of the parameter name environment variable. The parameter name is the name of the environment variable, and a pointer to that content is returned if the variable exists. The format of the environment variable is name=value.
return value:
Successful execution returns a pointer to the content, and null if no match is found for the environment variable name.
Example:
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h >
#include <stdlib.h>
main ()
{
char *p;
if (p = getenv ("USER"))
printf ("user=%s\n", p);
2.putenv (change or increase environment variable)
Related functions:
Getenv,setenv,unsetenv
Table header file:
#include4 <stdlib.h>
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/C/