Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <sys/stat.h>
- #include <sys/types.h>
- #include <dirent.h>
- #include <unistd.h>
- void list_dir(char *name) {
- DIR *dir;
- struct dirent *dp;
- struct stat statbuf;
- if ((dir = opendir(name)) == NULL) {
- perror("Blad");
- }
- while ((dp = readdir(dir)) != NULL) {
- if (stat(dp->d_name, &statbuf) == -1)
- continue;
- printf("%o %s\n", statbuf.st_mode, dp->d_name);
- }
- closedir(dir);
- }
- int main(int argc, char **argv) {
- char bufor[100];
- scanf("%s", bufor);
- list_dir(bufor);
- exit(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment