/ Published in: C
This simple code return the name of files
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#include <stdio.h> #include <dirent.h> #include <sys/types.h> #include <unistd.h> #include <sys/stat.h> #include <time.h> //coded by cobra90nj int main(int argc, char **argv) { struct dirent *drs; struct stat buf; DIR *dir; if (argc == 1) { dir = opendir("."); } else { dir = opendir(argv[1]); } while ((drs = readdir(dir)) != NULL) { stat(drs->d_name, &buf); } closedir(dir); }