31 lines
635 B
C
31 lines
635 B
C
#include <stdio.h>
|
|
#include <dirent.h>
|
|
#include <string.h>
|
|
|
|
int main() {
|
|
DIR *dir = opendir(".");
|
|
struct dirent *de;
|
|
|
|
if (!dir) {
|
|
perror("opendir");
|
|
return 1;
|
|
}
|
|
|
|
while ((de = readdir(dir)) != NULL) {
|
|
if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0)
|
|
continue;
|
|
|
|
if (de->d_type == DT_DIR) {
|
|
printf("\033[34m%s\033[0m ", de->d_name);
|
|
} else if (de->d_type == DT_REG) {
|
|
printf("%s ", de->d_name);
|
|
} else {
|
|
printf("%s ", de->d_name);
|
|
}
|
|
}
|
|
|
|
printf("\n");
|
|
closedir(dir);
|
|
return 0;
|
|
}
|