Linux下获取用户主目录的方法分享

方法如下

  char *path = getenv("HOME");

  printf("path = %s\n",path);

  getenv是标准库函数,包含stdlib.h头文件就可.