关于环境变量

来源:互联网 发布:淘宝退货诈骗 编辑:程序博客网 时间:2024/05/21 09:32

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dos.h>
int main(void)
{
 char *path, *ptr;
 int i = 0;
 /* get the current path environment */
 ptr = getenv("PATH");
 printf("%s/n",ptr);
 /* set up new path */
 path =(char *) malloc(strlen(ptr)+15);
 strcpy(path,"PATH=");
 strcat(path,ptr);
 strcat(path,";c://temp");
 /* replace the current path and display current environment */
 putenv(path);

 ptr = getenv("PATH");
 printf("%s/n",ptr);

 return 0;
 
     //还是要使用命令行参数  set
}