2011-10-12 73 views

回答

2

你应该有双引号。 getenv("HOME");

3
+1

你绝对需要双引号。 –

+0

谢谢。固定。自从我做了任何C编码以来,已经很久了。被困在PHP炼狱太久了。 –

5
#include <stdlib.h> 
... 
getenv("HOME") 
4

这不只是一个bash变量,它是一个环境变量。看看getenv

#include <stdlib.h> 

... 

// The value will be NULL if the variable doesn't exist 
char* home = getenv("HOME");