pwd - C equivalent

Discussion in 'C Programming' started by MN, Feb 27, 2009.

  1. MN

    MN Guest

    Is there any C function that returns the current working directory ?
    MN, Feb 27, 2009
    #1
    1. Advertising

  2. On 27 Feb 2009 at 12:37, MN wrote:
    > Is there any C function that returns the current working directory ?


    Yes:

    #include <unistd.h>

    char *getcwd(char *buf, size_t size);
    Antoninus Twink, Feb 27, 2009
    #2
    1. Advertising

  3. MN

    jacob navia Guest

    MN wrote:
    > Is there any C function that returns the current working directory ?


    getcwd

    --
    jacob navia
    jacob at jacob point remcomp point fr
    logiciels/informatique
    http://www.cs.virginia.edu/~lcc-win32
    jacob navia, Feb 27, 2009
    #3
  4. MN <> wrote:
    > Is there any C function that returns the current working directory ?


    If you mean with "C function" a function defined by the C standard
    then the answer is no since C doesn't require that the system has
    any concept of a "working directory". But, of course, there are
    system specific functions for that purpose. If yot are using e.g.
    a POSIX compliant system you could use getcwd().

    Regards, Jens
    --
    \ Jens Thoms Toerring ___
    \__________________________ http://toerring.de
    Jens Thoms Toerring, Feb 27, 2009
    #4
  5. MN

    Guest

    On 27 Feb, 12:37, MN <> wrote:

    > Is there any C function that returns the current working directory ?


    no, there is no function to do this in the standard library.
    This is platform specific so you need to ask on a platform
    specific newsgroup (Unix in your case)
    , Feb 27, 2009
    #5
  6. MN

    user923005 Guest

    On Feb 27, 4:37 am, MN <> wrote:
    > Is there any C function that returns the current working directory ?


    If you don't mind switching to C++, ACE will give you current working
    directory for the following:

    aix-5.x
    all
    cray
    cygwin32
    doxygen
    freebsd
    hpux-11.00
    integritySCA
    irix6.x
    linux
    lite
    lynxos
    macosx-panther
    macosx-tiger
    macosx
    macros
    minimal
    mvs
    netbsd
    openbsd
    openvms
    pharlap
    posix-nonetworking
    posix
    qnx-neutrino
    qnx-rtp-62x
    qnx-rtp-pre62x
    qnx-rtp
    rtems
    sco-5.0.0-nothread
    sco-5.0.0
    sunos5.10
    sunos5.4-g++
    sunos5.4-sunc++-4.x
    sunos5.5
    sunos5.6
    sunos5.7
    sunos5.8
    sunos5.9
    tandem-nsk-mips-v2
    tandem-nsk-mips-v3
    tandem
    tru64
    unixware-2.01-g++
    unixware-2.1.2-g++
    unixware-7.1.0
    unixware-7.1.0.udk
    visualage
    vxworks5.x
    vxworks6.2
    vxworks6.3
    vxworks6.4
    vxworks6.5
    win32
    WinCE

    Of course, for some platforms (e.g. your toaster's IC) current working
    directory is hard to put your finger on.
    user923005, Feb 28, 2009
    #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:
    440
  2. darrel

    PWD protecting individual files.

    darrel, Jun 19, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    326
    Shawn
    Jun 20, 2006
  3. Adam Smith
    Replies:
    2
    Views:
    368
    Adam Smith
    Dec 22, 2005
  4. Thauhtopa
    Replies:
    4
    Views:
    281
    Thauhtopa
    Dec 7, 2004
  5. PERL 'pwd' equivalent???

    , Sep 5, 2006, in forum: Perl Misc
    Replies:
    3
    Views:
    957
    John Bokma
    Sep 5, 2006
Loading...

Share This Page