我想使用C代码转到主目录。如何从代码访问$HOME?
发布于 2011-10-12 10:27:28
您应该使用双引号。getenv("HOME");
发布于 2011-10-12 10:22:09
#include <stdlib.h>
...
getenv("HOME")发布于 2011-10-12 10:23:10
它不仅仅是一个bash变量,它还是一个环境变量。看一看getenv
#include <stdlib.h>
...
// The value will be NULL if the variable doesn't exist
char* home = getenv("HOME");https://stackoverflow.com/questions/7734567
复制相似问题