#include #include #include #include #include #include int main (int argc, char **argv) { DIR * thisdir = opendir ("."); struct dirent *entry; while ((entry = readdir (thisdir)) != NULL) { struct stat st; char *dir; lstat (entry->d_name,&st); //file status info associated with the name if (S_ISDIR (st.st_mode)) dir = "yes"; //is this file a directory? else dir = "no"; //readdir gets the next filename out of the directory. printf ("%s\t%s\n",entry->d_name,dir); } } //The chdir system call changes your current working directory