[C++] 纯文本查看 复制代码
#include <stdlib.h>
int setenv(const char *name, const char *value, int overwrite);
int unsetenv(const char *name);
[C++] 纯文本查看 复制代码
#include <stdio.h>
#include <stdlib.h>
int main()
{
if (setenv ("SELDEF", "set_by_setevn_function", 1) != 0) {
perror ("setenv");
exit (EXIT_FAILURE);
}
printf ("Value of $SELDEF:%s\n",getenv("SELDEF"));
if (unsetenv("SELDEF") != 0) {
perror ("unsetenv");
exit (EXIT_FAILURE);
}
if (getenv("SELDEF") == NULL)
printf ("unsetenv successfully\n");
return 0;
}