Thread: Absolute path C

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    17

    Absolute path C

    Hello,

    Do anybody know, how could I get an absolute path? I tried this, but I have strange results...

    Code:
    #include <stdio.h>
    #include <unistd.h>
    #include <string.h>
    
    int main(int argc, char *argv) {
        char the_path[256];
    
        getcwd(the_path, 255);
        strcat(the_path, "/");
        strcat(the_path, argv[0]);
    
        printf("%s\n", the_path);
    
        return 0;
    }

  2. #2

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Buidl Library with ./configure script
    By Jardon in forum C Programming
    Replies: 6
    Last Post: 07-24-2009, 09:36 AM
  2. How to judge whether a path is relative or absolute?
    By bbebfe in forum C Programming
    Replies: 2
    Last Post: 11-16-2008, 03:23 AM
  3. Shortest path problem
    By Digitalxero in forum C++ Programming
    Replies: 0
    Last Post: 10-25-2005, 05:32 PM
  4. how to obtain the absolute application path
    By jagerhans in forum Linux Programming
    Replies: 4
    Last Post: 12-23-2004, 05:48 PM
  5. linked list recursive function spaghetti
    By ... in forum C++ Programming
    Replies: 4
    Last Post: 09-02-2003, 02:53 PM