Created
October 31, 2018 16:51
-
-
Save thinkphp/c39c2595dfccf3fad7fa629a2c5b50b5 to your computer and use it in GitHub Desktop.
Reads the contents of a root directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
This example reads the contents of a root directory. | |
Reference: https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.3.0/com.ibm.zos.v2r3.bpxbd00/rtread.htm | |
*/ | |
#include <stdio.h> | |
#include <dirent.h> | |
#include <errno.h> | |
int main() { | |
DIR *dir; | |
struct dirent *entry; | |
if((dir = opendir("/home/adrian")) == NULL) { | |
perror("opendir() error"); | |
} else { | |
puts("Contents of root:"); | |
while((entry = readdir(dir)) != NULL ) | |
printf(" %s\n", entry->d_name); | |
closedir( dir ); | |
} | |
return(0); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment