Hello fellow programmers,
I am having a problem running across a method of opening, reading filenames, and closing a directory in order to pull filenames with a certain extension from. In searching, the only reference I found to accomplish such a task was on the delorie/djgpp website. I am using Dev-C++ version 4.9.7.6. On the web site, they posted an example program to explain how it was used. Just for my sake, I tried the program and got some errors. Following is the program code and the errors. I am not asking for anybody to write my code, just for some knowledge in determining where the problem is.
****************ERRORS****************************Code:/*****************CODE**************************/ #include <sys/types.h> #include <dirent.h> /* Directory information.*/ main() { DIR * dir_p; struct dirent * dir_entry_p; /* Open the current directory*/ dir_p = opendir("."); /* read each entry until NULL.*/ while( NULL != (dir_entry_p = readdir(dir_p))) { /* print the name of the file held in * this directory entry.*/ printf(" %s \n", dir_entry_p->d_name); } /* Tidy up.*/ closedir(dir_p); }
[Linker error] undefined reference to `opendir'
[Linker error] undefined reference to `readdir'
[Linker error] undefined reference to `closedir'
************************************************** *
The code is exactly how it was downloaded as a file. I am just doing some testing in order to determine how to implement in to my own program. Any help would be greatly appreciated.
Thankfully,
Kendal



LinkBack URL
About LinkBacks


