Thanks for the suggestions.
Though still confused by pointers, I seem to have got it working thus:
Code:
static int check (const struct dirent *regcheck)
{
int rc;
regex_t * myregex = calloc(1, sizeof(regex_t));
if (NULL == myregex)
{
return 1;
}
// Compile the regular expression
rc = regcomp( myregex, "^.*\\.zip$", REG_EXTENDED | REG_NOSUB );
if (0 == regexec(myregex,regcheck->d_name, 0, 0, 0))
{
printf("Match: %s\n",regcheck->d_name);
return 1;
}
else
{
printf("Non-match: %s\n",regcheck->d_name);
return 0;
}
free(myregex);
}
Called by:
Code:
scandir(dir, &eps, check, alphasort);
As suggested it doesn't compile with the -ansi flag.