Dirent.h

Discussion in 'C++' started by sargonisaac@gmail.com, Feb 26, 2006.

  1. Guest

    I am trying to get Directory content list in VC++ 2003, here is my
    code:

    DIR *pdir;
    struct dirent *pent;
    char str[2000];
    pdir=opendir("./users/" + FullName); //"." refers to the current dir
    // if the dir doesnt exists, create it
    if (!pdir){
    mkdir("./users/" + FullName);
    }

    It says to use dirent.h and i cannot find it or it has not been found.
    Can someone please help, am i doing something wrong or is there another
    way of doing it???
     
    , Feb 26, 2006
    #1
    1. Advertising

  2. wrote:
    > I am trying to get Directory content list in VC++ 2003, here is my
    > code:
    >
    > DIR *pdir;
    > struct dirent *pent;
    > char str[2000];
    > pdir=opendir("./users/" + FullName); //"." refers to the current dir
    > // if the dir doesnt exists, create it
    > if (!pdir){
    > mkdir("./users/" + FullName);
    > }
    >
    > It says to use dirent.h and i cannot find it or it has not been found.
    > Can someone please help, am i doing something wrong or is there another
    > way of doing it???



    This is not standard C++ - hence off topic in this NG.

    Try a Microsoft NG -

    perhaps:
    microsoft.public.vc.language
     
    Gianni Mariani, Feb 26, 2006
    #2
    1. Advertising

  3. Moonlit Guest

    Hi,

    I might be wrong but I thought those functions are only available on unix.
    Under windows use:

    FindFirstFileEx

    and friends.

    Make sure to set the right WINNT version in the header otherwise you might
    be pretty puzzled about the messages you get :-(

    _WIN32_WINNT 0x400

    or something like that in StdAfx.h

    --


    Regards, Ron AF Greve

    http://moonlit.xs4all.nl

    <> wrote in message
    news:...
    >I am trying to get Directory content list in VC++ 2003, here is my
    > code:
    >
    > DIR *pdir;
    > struct dirent *pent;
    > char str[2000];
    > pdir=opendir("./users/" + FullName); //"." refers to the current dir
    > // if the dir doesnt exists, create it
    > if (!pdir){
    > mkdir("./users/" + FullName);
    > }
    >
    > It says to use dirent.h and i cannot find it or it has not been found.
    > Can someone please help, am i doing something wrong or is there another
    > way of doing it???
    >
     
    Moonlit, Feb 26, 2006
    #3
  4. wrote:
    > I am trying to get Directory content list in VC++ 2003, here is my
    > code:
    >
    > DIR *pdir;
    > struct dirent *pent;
    > char str[2000];
    > pdir=opendir("./users/" + FullName); //"." refers to the current dir
    > // if the dir doesnt exists, create it
    > if (!pdir){
    > mkdir("./users/" + FullName);
    > }
    >
    > It says to use dirent.h and i cannot find it or it has not been found.
    > Can someone please help, am i doing something wrong or is there another
    > way of doing it???
    >


    This is Unix/Linux code (DIR, opendir(), dirent).
    Do the Microsoft headers/libs support/contain these functions
    and structures?

    Also, opendir() and mkdir() take C strings (char *) as their
    args, not C++ std::string args. So the syntax like

    "./users/" + FullName

    won't work.

    Larry
     
    Larry I Smith, Feb 26, 2006
    #4
    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. Martin Pohlack

    sizeof(struct dirent.d_ino)

    Martin Pohlack, Sep 8, 2003, in forum: C Programming
    Replies:
    19
    Views:
    1,121
    Keith Thompson
    Sep 10, 2003
  2. **--> That Guy Downstairs
    Replies:
    14
    Views:
    748
    S7Solutions
    Feb 21, 2006
  3. Replies:
    9
    Views:
    550
    P.J. Plauger
    May 10, 2006
  4. eddie

    Need help with struct *** dirent ???

    eddie, Jan 10, 2009, in forum: C Programming
    Replies:
    7
    Views:
    527
    Richard
    Jan 12, 2009
  5. Sascha Wüstemann
    Replies:
    4
    Views:
    1,119
    Ike Naar
    Aug 3, 2011
Loading...

Share This Page