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 derfloh 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
Joined
Dec 28, 2003
Messages
83
Location
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.

Similar threads

  • Locked
  • Question Question
Replies
4
Views
472
Replies
2
Views
402
Replies
1
Views
296
  • Locked
  • Question Question
Replies
4
Views
334

Part and Inventory Search

Sponsor

Back
Top