Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

opendir() question

Status
Not open for further replies.

room24

Programmer
Dec 28, 2003
83
JM
how do actually use opendir() to open someone's home directory. what value would you pass to opendir on unix to make it open the home directory
 
I believe that this is what you are asking. You can get the user's home directory by reading the environment variable 'HOME'.

Like this:

Code:
  char *homedir;
  DIR *dir;

  homedir = getenv ( "HOME");
  if (NULL == homedir) {} // do something
  else dir = opendir(homedir);


Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top