pwd

Discussion in 'C Programming' started by vertigo, Sep 12, 2004.

  1. vertigo

    vertigo Guest

    Hello
    How can i read current working directory in unix
    (from c program) ?

    Thanx
    Michal
     
    vertigo, Sep 12, 2004
    #1
    1. Advertising

  2. vertigo

    Markus Pitha Guest

    Hello,
    Im not sure, what you exactly mean with current directory, but is
    something like this, what yousearch for?

    #include <stdio.h>

    int main(void) {
    char tmp[20];
    sprintf(tmp, "ls -al");
    system(tmp);

    return 0;
    }


    > Hello
    > How can i read current working directory in unix
    > (from c program) ?
    >
    > Thanx
    > Michal
     
    Markus Pitha, Sep 12, 2004
    #2
    1. Advertising

  3. vertigo

    Markus Pitha Guest

    Sorry, acutally you don't need sprintf.
    system("ls -al"); does it as well.
    I used sprintf because i always had to combine some strings in one order.
     
    Markus Pitha, Sep 12, 2004
    #3
  4. On Sun, 12 Sep 2004 17:48:52 +0200, in comp.lang.c , vertigo <>
    wrote:

    >Hello
    >How can i read current working directory in unix
    >(from c program) ?


    By using unix-specific function calls. You'd need to ask in a unix
    programming group about that, as ISO C doesn't support any specific
    platform
    --
    Mark McIntyre
    CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
    CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>


    ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
     
    Mark McIntyre, Sep 12, 2004
    #4
  5. vertigo

    c453___ Guest

    try those:
    #include <dirent.h>
    opendir() , readdir()
     
    c453___, Sep 12, 2004
    #5
  6. vertigo

    guggach Guest

    hi
    does he not speaks about:
    current working directory in unix in 'c'
    ?????????
    google for 'unix man getcwd


    -
    guggac
    -----------------------------------------------------------------------
    Posted via http://www.codecomments.co
    -----------------------------------------------------------------------
     
    guggach, Sep 14, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vn
    Replies:
    2
    Views:
    456
  2. darrel

    PWD protecting individual files.

    darrel, Jun 19, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    345
    Shawn
    Jun 20, 2006
  3. Adam Smith
    Replies:
    2
    Views:
    387
    Adam Smith
    Dec 22, 2005
  4. absoft
    Replies:
    3
    Views:
    729
    dotnet dude
    Sep 6, 2006
  5. Thauhtopa
    Replies:
    4
    Views:
    318
    Thauhtopa
    Dec 7, 2004
Loading...

Share This Page