获取环境变量
2015-06-25 11:55
465 查看
#include <stdlib.h> int main(int argc, char *argv[]) { const char *tmppath = "/tmp"; const char *user = ""; /** * in UNIX/Linux os, uses /tmp direcotry to store temp file, while in * Windows os, using `TMP' environment variable indicate the temp directory. * * and using `USER' environment variable in UNIX/Linux, but in Windows os, * it uses `USERNAME' to store logon user. */ #ifdef _WIN32 tmppath = getenv("TMP"); /* without the last '\\' */ user = getenv("USERNAME"); #else user = getenv("USER"); #endif /* _WIN32 */ /* use the same `HOME' environment variable in Unix/Linux and Windows */ const char *homedir = getenv("HOME"); return 0; }
相关文章推荐
- 多尺度滑动窗口法,multiple-scale sliding window method
- 20150625
- intellij的一些设置和快捷键
- IOS字典转模型
- spring对hibernate的支持详解
- spring MVC跳转到dorado的view.xml文件时出错
- javascript实现跨域的方法汇总
- SpringMVC获取请求参数的方法
- ubuntu开发环境搭建
- 常见设计模式结构图助记之创建型
- 在Linux下运行可执行Jar包
- delete和delete[]的真正区别
- iOS CALayer 抖动效果
- rman备份恢复命令之switch
- 并发队列ConcurrentLinkedQueue和阻塞队列LinkedBlockingQueue用法
- unity 在移动平台中,文件操作路径详解
- Toolbar的完全自定义
- [学习笔记—Objective-C]《Objective-C 程序设计 第6版》第三章 类,对象和方法 课后题解析 3-7
- emacs 调试时查看全局变量
- 关于collectionView和tableView的两种cell的出列方法的区别