环境变量 [英] environmental variables

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

问题描述

您好!


如何获取环境变量的所有细节。如果我使用

getenv,我将必须指定变量的名称。对于intsance我

必须给getenv(PATH)


如何获得所有变量的信息,变量为

名称及其价值


请帮助


Casanova

Hello!!

how can i get all the details of the environmental variables. If i use
getenv, i will have to specify the name of the variable. for intsance i
will have to give getenv("PATH")

How can i get the information of all the variables, with the variable
names and its values

Pls Help

Casanova

推荐答案

/ *

这个程序应该打印所有的环境变量。

* /

# include< stdio.h>

int main(int argc,char * argv [],char * envp [])

{

for(int i = 0; envp [i]!= NULL; ++ i)

{

printf("%s \ n",envp [i ]);

}


返回0;

}

" Casanova" < PR ******** @ gmail.com>在消息中写道

news:11 ********************** @ z14g2000cwz.googlegr oups.com ...
/*
This program should print all the environment variables.
*/
#include <stdio.h>
int main( int argc, char *argv[], char *envp[] )
{
for( int i = 0; envp[i] != NULL; ++i )
{
printf("%s\n", envp[i]);
}

return 0;
}
"Casanova" <pr********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
你好!!

如何获得环境变量的所有细节。如果我使用
getenv,我将必须指定变量的名称。对于intsance我将不得不给getenv(PATH)

如何获得所有变量的信息,变量名称及其值

请帮助

Casanova
Hello!!

how can i get all the details of the environmental variables. If i use
getenv, i will have to specify the name of the variable. for intsance i
will have to give getenv("PATH")

How can i get the information of all the variables, with the variable
names and its values

Pls Help

Casanova



Satya Das< sa ********* *****@yahoo.com>潦草地写道:
Satya Das <sa**************@yahoo.com> scribbled the following:
/ *
这个程序应该打印所有环境变量。
* /


只在某些实现上。

#include< stdio.h>
int main(int argc,char * argv [],char * envp [])


这种形式的main()是非标准的并且会导致不确定的行为。

它可能适用于某些实现,但不能保证在任何实现上工作



{
for(int i = 0; envp [i]!= NULL; ++ i)
{/> printf("%s \ n",envp [ i]);
}
返回0;
}
/*
This program should print all the environment variables.
*/
Only on some implementations.
#include <stdio.h>
int main( int argc, char *argv[], char *envp[] )
This form of main() is non-standard and causes undefined behaviour.
It might work for some implementations but is not guaranteed to work
on any.
{
for( int i = 0; envp[i] != NULL; ++i )
{
printf("%s\n", envp[i]);
} return 0;
}




-

/ - Joona Palaste(pa*****@cc.helsinki.fi)-------------芬兰-------- \

\ -------------------------------------------------- ------规则! -------- /

我再也不会公开露面了。

- 荷马辛普森



--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"I will never display my bum in public again."
- Homer Simpson


Joona I Palaste写道:
Joona I Palaste wrote:
Satya Das< sa ************** @ yahoo.com>潦草地写了下面的内容:
Satya Das <sa**************@yahoo.com> scribbled the following:
/ *
这个程序应该打印所有的环境变量。
* /
/*
This program should print all the environment variables.
*/



Only在某些实现中。


Only on some implementations.

#include< stdio.h>
int main(int argc,char * argv [],char * envp [])
#include <stdio.h>
int main( int argc, char *argv[], char *envp[] )



这种形式的main()是非标准的,会导致未定义的行为。


This form of main() is non-standard and causes undefined behaviour.




嗯,C99标准中说5.1.2.2.1程序启动,main()是

定义

a)...没有参数

b)" ; ...或者带有两个参数

c)......,或者用其他一些实现定义的方式。


那是'没有未定义,不应该导致鼻子守护进程或任何东西

别的,是吗? ;-)


Bj?

[snip]



Hmm, the C99 standard says in 5.1.2.2.1 Program startup, that main() is
defined
a) "... with no parameters"
b) "... or with two parameters"
c) "..., or in some other implementation-defined manner".

That''s not undefined and should not cause nasal daemons or anything
else, should it? ;-)

Bj?rn
[snip]


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

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