Created
August 25, 2024 07:58
-
-
Save mortymacs/556827fc48ef6e7c3f6656799a0fb9d9 to your computer and use it in GitHub Desktop.
Read dir in C
This file contains hidden or 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
#include <stdio.h> | |
#include <dirent.h> | |
#include <sys/types.h> | |
int main() | |
{ | |
struct dirent *entry; | |
DIR *dir; | |
dir = opendir("/home/user1/"); | |
while((entry = readdir(dir)) != NULL) | |
{ | |
printf("%s [%d]\n", entry->d_name, entry->d_type); | |
} | |
closedir(dir); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment