scandir select function

This is a discussion on scandir select function within the C Programming forums, part of the General Programming Boards category; I want to know how to use the select part or the scandir function..
My program wants to ignore hidden ...

scandir select function

I want to know how to use the select part or the scandir function..

My program wants to ignore hidden files when scanning a directory, so i wrote a function called 'matchDetails' which checks if the file passed to it is hidden or not.
-- it is hidden it returns 0.
-- it is not hidden it returns 1.

What select should do is,, select results from scanning the directory and ignore any results that return a 0.

Code:

count = scandir(cwdir,&direntp,matchDetails,alphasort);

As you can see from above i have put the matchDetails function in the select argument space.. so all hidden files should be ignored.

this is a quote of what the scandir and select function should do:

The scandir() function scans the directory dir, calling
select() on each directory entry. Entries for which
select() returns non-zero are stored in strings allocated
via malloc(), sorted using qsort() with the comparison
function compar(), and collected in array namelist which
is allocated via malloc(). If select is NULL, all entries
are selected.

What matchDetails does is takes one file and checks using the regular expression, if it is a hidden file (hidden files have dots .. ).
If it is a hidden file then it returns 0
if it is not hidden then it returns 1

i dont want the hidden files listed so thats what the purpose of matchDetails is..

i want it so scandir does not list hidden files,, therefore,, i have created a LS -L and not a LS -AL..