Issue with S_ISDIR() result in C (maybe because stat() isn't setting its struct properly?)
问题 I want my program to take a directory, then print the contents of that directory and state whether or not each item is a directory or not. If I give it a directory containing files F1.txt and F2.txt and folders D1, D2, and D3, it should print: F1.txt is not directory F2.txt is not directory D1 is directory D2 is directory D3 is directory char* curr[100]; DIR* dirp = opendir(name); struct dirent* x; struct stat fstat; //go to each file til readdir gives NULL while((x = readdir(dirp)) != NULL)