2011-10-12 68 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");