|
-
July 17th, 2002, 02:30 AM
#1
_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
-
July 17th, 2002, 06:21 AM
#2
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);
}
}
-
July 17th, 2002, 08:35 AM
#3
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
-
July 30th, 2002, 10:38 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|