c++ - 在 C++ 中设置本地环境变量

如何在 C++ 中设置环境变量?

  • 他们不需要坚持过去的程序执行
  • 它们只需要在当前进程中可见
  • 偏好平台独立,但我的问题只需要在 Win32/64 上工作

谢谢

最佳答案

NAME

       putenv - change or add an environment variable

SYNOPSIS

       #include <stdlib.h>

       int putenv(char *string);

DESCRIPTION
       The  putenv()  function adds or changes the value of environment
       variables.  The argument string is of the form name=value.  If name does
       not already exist in the environment, then string is added  to  the
       environment.   If name does exist, then the value of name in the
       environment is changed to value.  The string pointed to by string becomes
       part of the environment, so altering the string changes the environment.

我相信在 Win32 上它被称为 _putenv。

见 SetEnvironmentVariable如果你喜欢又长又丑的函数名。

https://stackoverflow.com/questions/899517/

相关文章:

c++ - C 和 C++ 标准之间的关系是什么?

c++ - 如何轻松查看 C/C++ #include 图?

c++ - 为 Windows 编写超薄 C++ 程序(如 uTorrent)

c++ - 特殊情况: Is & faster than %?

c++ - 标准的 atomic bool 和 atomic flag 之间的区别

c++ - std::this_thread::yield() 与 std::this_thread

c++ - 向 Python 公开 C++ API

c++ - 在函数模板中使用静态局部变量的地址作为类型标识符是否安全?

c++ - 架构 x86_64 : Compiling problems 的 undefined s

c++ - 我真的需要为 const 对象实现用户提供的构造函数吗?