I'm trying to find a way to get a list of only the files inside a directory. If that directory has other sub-directories in it, I don't want them in the list.

I'm currently using scandir like this:

char *pathname = "/var/";

int count, i;
struct direct **files;

count = scandir(pathname, &files, file_select, alphasort);

for (i=1; i<count+1; ++i)
printf("%s\n", files[i-1]->d_name);

I've looked around and can't find an easy way to check to see if an element in files is a directory or a file.

Can anyone give me a suggestion?

First time poster.