GETENV()? [英] getenv()?

查看:74
本文介绍了GETENV()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

getenv()做什么以及为什么要使用它?

What does getenv() do and why would you use it?

推荐答案

Protoman写道:
Protoman wrote:
getenv()做什么以及你为什么要使用它?
What does getenv() do and why would you use it?




man getenv。


它返回一个指针到null终止的字符串,其值为

环境。


#include< cstdlib>

#include< iostream>

int main()

{

std :: cout<< std :: getenv(" PWD")<< std :: endl;

}



man getenv.

It returns a pointer to the null terminated string having a value from
the environment.

#include <cstdlib>
#include <iostream>
int main()
{
std::cout << std::getenv("PWD") << std::endl;
}


例如,因为你实现了一个新的算法,可以使用这个函数

并保留旧的算法,你可以定义一个envvar,它将允许你在新老算法之间切换
。通过这种方式你定义一个if(getenv(...))

来确定将运行哪个算法。


Stef

Neelesh Bodas <是ne *********** @ gmail.com> écritdansle message de news:
11**********************@g47g2000cwa.googlegroups。 com ...
This function can be used for example because you implement a new algorithm
and to keep the old algo you can define an envvar that will allow you to
switch between old and new algo. By this way you define an if(getenv(...))
to determine which algo will be run.

Stef
"Neelesh Bodas" <ne***********@gmail.com> a écrit dans le message de news:
11**********************@g47g2000cwa.googlegroups. com...
Protoman写道:
Protoman wrote:
getenv()做什么以及为什么要使用它?
What does getenv() do and why would you use it?



man getenv。
它返回一个指向空终止字符串的指针,该字符串具有来自环境的值。

#include< cstdlib>
#include< iostream>
int main()
{
std :: cout<< std :: getenv(" PWD")<< std :: endl;
}



man getenv.

It returns a pointer to the null terminated string having a value from
the environment.

#include <cstdlib>
#include <iostream>
int main()
{
std::cout << std::getenv("PWD") << std::endl;
}



那么,环境变量是什么?如何定义?

So, what''s an enviroment variable and how do I define one?


这篇关于GETENV()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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