1、getenv函数

  头文件:#include<stdlib.h>

  函数原型: char * getenv(const char* name);

  函数说明:getenv()用来取得参数name环境变量的内容。

  函数参数:name为环境变量的名称,如果该变量存在则会返回指向该内容的指针。环境变量的格式为name=value。

  返回值:若环境变量存在,返回环境变量值的指针,否则返回NULL

  

  例子:

 1 #include <stdlib.h>
 2 #include <stdio.h>
 3 int main()
 4 {
 5     char* path = NULL;
 6     if((path = getenv("USER")))
 7         printf("USER = %s\n", path);
 8 
 9     return 0;
10 }
View Code

相关文章:

  • 2021-08-21
  • 2021-08-12
  • 2021-11-10
  • 2022-01-26
  • 2021-08-09
  • 2021-10-20
  • 2022-03-01
  • 2022-12-23
猜你喜欢
  • 2021-09-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-12
相关资源
相似解决方案