Who knows a function that list a path immediate files list ?

This is a discussion on Who knows a function that list a path immediate files list ? within the C Programming forums, part of the General Programming Boards category; Hello. I need a function that receives a path, an returns a list of the immediate files. Is someone can ...

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    2

    Lightbulb Who knows a function that list a path immediate files list ?

    Hello.
    I need a function that receives a path, an returns a list of the immediate files.

    Is someone can help me?

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    This is platform specific and you will probably have to write it yourself. Though you can search for third party functions that do what you want. What OS and compiler do you use?

    -Prelude
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Jul 2002
    Posts
    2

    Lightbulb Prelude : Thnks for youe reply...

    I need it for two platforms:
    1. NT-4 + VC5
    2. gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-81)
    Rami.

  4. #4
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    There are some standard c functions for doing this. Dirent.h contains the functions for doing this kind of stuff. Since I don't feel like writing code just look on google.

  5. #5
    Registered User
    Join Date
    Jul 2002
    Posts
    52
    try something like this:
    Code:
    #include <stdio.h>
    #include <dirent.h>
    
    int main()
    {
         struct dirent *foo=NULL; 
         DIR *bar=NULL;
         char ham[lengthoffilename][numberofentries];
         char* filename="why/didnt/you/search/the/web";
         bar=opendir(filename); /*this opens the dir-big surprise*/
         /*check for NULL pointer here*/
         while (foo == readdir(bar)){
                  /*set up a for loop here and read*/
                  ham[][i] = foo->d_name
         }
         closedir(bar);
         return 0;
    }
    Something like that might work for you. But then again, it might not.
    Turn no more aside and brood
    Upon love's bitter mysteries
    For Fergus rules the brazen cars...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  2. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  3. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  4. compiler build error
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 11-30-2003, 09:16 AM
  5. linked list recursive function spaghetti
    By ... in forum C++ Programming
    Replies: 4
    Last Post: 09-02-2003, 02:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21