Change cwd to Home

This is a discussion on Change cwd to Home within the C Programming forums, part of the General Programming Boards category; I've been thinking about a way to do this, and have also search this forum, google and the unix man ...

  1. #1
    Wannabe Coding God
    Join Date
    Mar 2003
    Posts
    259

    Change cwd to Home

    I've been thinking about a way to do this, and have also search this forum, google and the unix man pages, and what I've come up with is to use getwuid to get the users home direcotry and then use chidr with the home path I got from getwuid and then use scandir to show the continens of the users home direcotry. My Question is, if this is a good way of doing it and if there is some other way which might be recommended to use?
    They say that if you play a Windows Install CD backwords, you hear satanic messages. That's nothing; play it forward and it installs Windows.

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,169
    Does your main goal include changing to that directory or just displaying the contents of it?
    If you understand what you're doing, you're not learning anything.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    My Question is, if this is a good way of doing it and if there is some other way which might be recommended to use?
    Does it work if you do it that way? Can you understand the code you've written? Is it clean and understandable? If yes to the above, then it sounds like it's a pretty good way to do it.

    Code:
    success = !chdir( "~" );
    if( success )
        foo( );
    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. c++builder6 change form names problem
    By Leite33 in forum C++ Programming
    Replies: 2
    Last Post: 06-09-2008, 08:20 AM
  2. how to change static char* and not lose mem ?
    By jabka in forum C Programming
    Replies: 15
    Last Post: 09-07-2007, 05:33 PM
  3. Change Value in an array
    By beginner999 in forum C Programming
    Replies: 3
    Last Post: 01-18-2003, 06:16 AM
  4. Replies: 2
    Last Post: 11-08-2002, 02:22 AM
  5. Replies: 2
    Last Post: 09-04-2001, 02:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21