Bonsoir,
quand je lance l'executable pour un seul fichier ou un seul repertoire il m'affiche rien
> ./toto ls.c
>

par contre pour plusieur il m'affiche :
> ./toto *
48 2005-06-18 19:54:30 2005-09-22 20:49:39 2005-06-18 19:54:30

voila le code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
 
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
 
#define FMT_TIME "%Y-%m-%d %T" 
 
int compar_size (const void *pt_a, const void *pt_b)
{
   const struct stat *pt_sa = pt_a;
   const struct stat *pt_sb = pt_b;
   return pt_sa->st_size - pt_sb->st_size;
  // return pt_sa->st_mtime - pt_sb->st_mtime;
}
 
int main (int argc, char *argv[])
{
  int mode;
  char * patch=NULL;
  char date1[30];
  char date2[30];
  char date3[30];
  int i;
  int Max = argc -1; 
 
  struct stat *sbuf =malloc (Max * sizeof *sbuf);
  if (sbuf != NULL)
  {
    int result = 0;
    for (i=0; !result && i < Max; i++)
    {
      result=stat(argv[i],&sbuf[i]);
    }
    if (!result)
    {
      qsort(sbuf, Max, sizeof *sbuf, compar_size);
      for(i=1; i <Max; i++)
      {
        mode = sbuf[i].st_mode;
 
        patch=argv[i];
        strftime (date1,Max,FMT_TIME,gmtime(&sbuf[i].st_mtime));
        strftime (date2,Max,FMT_TIME,gmtime(&sbuf[i].st_atime));
        strftime (date3,Max,FMT_TIME,gmtime(&sbuf[i].st_ctime));
        if (S_ISDIR (mode)) 
        {
          printf("%10lu %s %15s\n", (unsigned long)sbuf[i].st_size, date3, patch);
        }
        if (S_ISREG (mode))
        {
          printf("%10lu %s %15s\n", (unsigned long)sbuf[i].st_size, date3, patch);
        }
      }  
    }
    else 
    {
      printf("Problem getting information\n");
      perror(argv[i + 1]);
    }
    free (sbuf), sbuf=NULL;
  }
    return 0;
}
Merci d'avance