在C设置本地环境变量++ [英] Set local environment variables in C++

查看:105
本文介绍了在C设置本地环境变量++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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


  • 他们并不需要坚持过去的程序执行

  • 他们只需要可见在当前进程

  • 对于独立于平台的,但我的问题
  • preference只需要在Win32 / 64
  • 工作

感谢


解决方案


名称       传给putenv - 更改或添加环境变量概要       的#include&ltstdlib.h>       INT传给putenv(字符*字符串);描述
       该putenv()函数的功能添加或更改环境的价值
       变量。参数字符串的形式为名称=值。如果NAME
       未在环境中已经存在,则字符串被添加到
       环境。如果名称不存在,则在名称的值
       环境改变成的值。该字符串指向字符串变成
       环境的一部分,因此,改变了字符串改变了环境。

在Win32的,它被称为_putenv我相信。

请参阅 SetEnvironmentVariable方法此外,如果你是长期的和丑陋的函数名的粉丝。

How do I set an environment variable in C++?

  • They do not need to persist past program execution
  • They only need to be visible in the current process
  • Preference for platform independent but for my problem only needs to work on Win32/64

Thanks

解决方案

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.

On Win32 it's called _putenv I believe.

See SetEnvironmentVariable also if you're a fan of long and ugly function names.

这篇关于在C设置本地环境变量++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆