Click to See Complete Forum and Search --> : _findfirst in MicroSoft C


jesvh
July 17th, 2002, 02:30 AM
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 !!

:confused: ----- jesvh

PaulWendt
July 17th, 2002, 06:21 AM
#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);
}
}

Paul McKenzie
July 17th, 2002, 08:35 AM
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 !!

:confused: ----- 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

jesvh
July 30th, 2002, 10:38 PM
Thanks !!

It help great !!