getenv函数
来源:互联网 发布:移动数据终端 华为 编辑:程序博客网 时间:2024/05/22 05:25
函数名: getenv
功 能: 从环境中取字符串,获取环境变量的值
头文件: stdlib.h
用 法:char *getenv(char *envvar);
函数说明:getenv()用来取得参数enwar环境变量的内容。参数enwar为环境变量的名称,如果该变量存在则会返回指向该内容的指针。环境变量的格式为enwar=value
返回值: 执行成功则返回指向该内容的指针,找不到符合的环境变量名称则返回NULL
相关函数:_wgetenv、getenv_s、_wgetenv_s
程序示例
程序例1: #include <stdlib.h>
#include <stdio.h>
int main(void)
{
char *s;
s=getenv("COMSPEC"); /* get the comspec environment parameter */
printf("Command processor: %s/n",s); /* display comspec parameter */
return 0;
}
执行:COMSPEC = name
程序例2:
下面这个例子来自MSDN[1]
#include <stdlib.h>
#include <stdio.h>
int main( void )
{
char *libvar;
libvar = getenv( "LIB" ); // C4996
if( libvar != NULL )
printf( "Original LIB variable is: %s/n", libvar );
_putenv( "LIB=c://mylib;c://yourlib" ); // C4996
libvar = getenv( "LIB" ); // C4996
if( libvar != NULL )
printf( "New LIB variable is: %s/n", libvar );
return 0;
}
- getenv ()函数
- getenv()函数
- getenv函数
- getenv函数
- getenv()函数
- getenv()函数
- PHP中getenv()函数
- getenv()函数介绍
- getenv()函数
- PHP中getenv函数
- 函数名: getenv()
- getenv,putenv,setenv函数
- C中getenv()函数
- getenv、setenv函数
- php getenv()函数
- PHP中 getenv()函数 (环境变量)
- c函数之getenv()实例
- getenv、putenv和setenv函数
- gettimeofday()
- 认真对待每一天
- 用javascript中的DOM实现分页编辑删除
- document.body和document.documentElement,document.compatMode的关系
- linux下的c/c++调试器gdb
- getenv函数
- strtol函数
- localtime函数
- fflush函数
- 教育的真正目的,是让一个人可以连续发问。
- 开始
- access函数
- 时间
- java高级