I have to read a directory name and print directory's index (type of each file and date of the last modification).
1 #include <stdio.h>
2 #include <sys/stat.h>
3 #include <dirent.h>
4 #include <sys/types.h>
5
6 int main() {
7 char file[100];
8 struct stat stats;
9 DIR *dr;
10 struct dirent *en;
11 char location[500];
12 dr = opendir(".");
13 if (dr) {
14 while ((en = readdir(dr)) != NULL) {
15 printf("%s\n", en->d_name);
16 properties(en);
17 }
18 closedit(dr);
19 }
20 else{
21 printf("File not found! Check if there is the %s\n", file);
22 }
23 return 0;
24
25 void **properties**(struct stat stats)
26 {
27 if (stats.st_mode & R_OK){
28 printf("Read ");
29 if (stats.st_mode & W_OK)
30 printf("Write ");
31 if (stats.st_mode & X_OK)
32 printf("Exe");
33 }
34 if (stats.st_size != 0)
35 printf("\nFile Size: %d\n", stats.st_size);
36 }
37 }
So my question is, why the declaration "properties" (declared at line 25) is incompatible with previous "properties" (declared at line 16). Also why my compiler is asking me a ";" at line 26.
Thanks!