Traversing through Directories in C
问题 I am trying to traverse through a directory whose path is given but the following program is not going inside the directories and is stuck in infinit loop. What is the problem in this code: void func(char path[]); int main(int argc, char *argv) { char buf[255]; getcwd(buf,255); func(buf); } void func(char path[]) { DIR *dirp; struct stat states; struct dirent *direntp; dirp=opendir(path); chdir(path); while((direntp=readdir(dirp))!=NULL) { if(S_ISDIR(states.st_mode))//true than returns zero {