Linux下获取用户主目录的方法分享 char *path = getenv("HOME"); printf("path = %s ",path); getenv是标准库函数,包含stdlib.h头文件就可.