CaptRage61
Programmer
I want to create a method to search for a given file(or directory) in a given directory, here is what I came up with but it always says that it was not found even if the file exists.
Any ideas on how to get this to work
Code:
void search ( char *filename , char *dirname ){
struct dirent *dirPointer;
DIR *d;
d = opendir( dirname );
//had code to print error message but took out to save space
while ( (dirPointer=readdir(d)) != NULL ) {
if ( dirPointer->d_name == filename ) {
// print absolute path of file
printf("File located\n");
}
else printf("%s Not found in %s\n",filename , dirname );
}
}
Any ideas on how to get this to work