CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2002
    Posts
    56

    Question _findfirst in MicroSoft C

    Hello :

    In MicroSoft C/C++ , there are functions ( _findfirst, _findnext ... )
    used to look for files with wildcard characters , but none of them
    exist in Unix C/C++ .

    example :

    find all files named like "demo_*.*"

    Are there similar functions exist in Unix C/C++ ? ( don't use system() function )

    If not , how to implement them with simplest methods ?

    Thanks !!

    ----- jesvh

  2. #2
    Join Date
    May 2000
    Location
    Phoenix, AZ [USA]
    Posts
    1,347
    Code:
    #include <stdio.h>
    int main(int argc, char* argv[])
    {
       FILE* pSearch;
       FILE* popen();
       char   buffer[2048] = {0};
    
       if ((pSearch = popen("ls -al", "r")) != NULL)
       {
          fscanf(buffer, "%s", pSearch);
          pclose(pSearch);
       }
    }

  3. #3
    Join Date
    Apr 1999
    Posts
    27,449

    Re: _findfirst in MicroSoft C

    Originally posted by jesvh
    Hello :

    In MicroSoft C/C++ , there are functions ( _findfirst, _findnext ... )
    used to look for files with wildcard characters , but none of them
    exist in Unix C/C++ .

    example :

    find all files named like "demo_*.*"

    Are there similar functions exist in Unix C/C++ ? ( don't use system() function )

    If not , how to implement them with simplest methods ?

    Thanks !!

    ----- jesvh
    The functions you are looking for are opendir(), readdir(), and closedir().

    Here is a link:

    http://www.tac.eu.org/cgi-bin/man-cgi?readdir+3

    Regards,

    Paul McKenzie

  4. #4
    Join Date
    Mar 2002
    Posts
    56
    Thanks !!

    It help great !!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured