每一个环境变量的表示形式为:
环境变量名 = 环境变量值(最后有一个‘\0’结束符)。
1、得到一个环境变量,函数原型为:
#include<stdlib.h>
char *getenv(const char *name);
getenv 中变量name直接选择环境变量的值,例如:HOME。
2、设置一个环境变量,函数原型为:
#include<stdlib.h>
int putenv(char *str);
putenv中变量str需要使用name = value的字符串。
#include<stdlib.h>
int setenv(const char *name, const char *value, int rewrite);
setenv中变量name直接选择环境变量的值。