Thread: getting the home directory

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    161

    getting the home directory

    Hi, a quick question.. what's the fastest way to retrieve the home dir under windows?

    thanx
    This forum is the best one I've ever seen. Great ppl, great coders

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Code:
    #include <stdio.h>
    
    int main ( void )
    {
      FILE *cl = _popen ( "echo %USERPROFILE%", "r" );
      char buff[1024];
    
      fgets ( buff, sizeof buff, cl );
      printf ( "%s", buff );
    
      _pclose ( cl );
    
      return 0;
    }
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    161
    thanx
    This forum is the best one I've ever seen. Great ppl, great coders

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Couple errors please help :-D
    By JJJIrish05 in forum C Programming
    Replies: 9
    Last Post: 03-06-2008, 02:54 AM
  2. Not able to access directory of home folder
    By Bargi in forum Linux Programming
    Replies: 1
    Last Post: 02-06-2008, 02:45 AM
  3. how to get current user home directory
    By George2 in forum Linux Programming
    Replies: 4
    Last Post: 05-08-2007, 02:46 PM
  4. Accessing the 'home' directory path?
    By smoothdogg00 in forum C Programming
    Replies: 3
    Last Post: 04-30-2006, 10:51 AM