End game was to compare the extensions of files in the directory to 2 separate string of arrays to that i could sort it and put it 2 different folders..
I am having a problem comparing the strings of two different arrays.. esp with 2 different sized string arrays..
any suggestions is appreciated..
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
#include <string.h>
int main (void)
{
DIR *dirP;
struct dirent *dp;
char *fileN; int i = 0;
char *extMov[]= {".mp4",".flv"};
char *extMusic[]= {".mp3"};
dirP = opendir ("/Users/abc/Downloads");
if (dirP != NULL)
{
while ((dp = readdir(dirP)) != NULL)
{
if((fileN = strrchr(dp->d_name,'.')) != NULL)
{
for (i=0; extMov[i] != NULL; i++)
{
if(strcmp (fileN,extMov[i]) == 0)
{
printf("%s\n",dp->d_name);
}
}
}
}
closedir(dirP);
}
else
perror (" Could not open the directory\n");
return 0;
}