#include <stdio.h>
#include <string.h>
#include <io.h>
#include <time.h>

void traiteFichier(char *name) {
  printf("--> %s\n",name);
  FILE *f;
  f = fopen(name,"rb");
  char name2[500];
  strcpy(name2,name);
  strcat(name2,"2");
  FILE *f2 = fopen(name2,"wb");
  char c;
  if ( f ) {
    fread((void *)&c,1,1,f) ;
    while ( !feof(f) ) {
      if ( c == '\t' ) {
        fwrite("        ",2,1,f2);
        printf("*"); }
        else
        fwrite(&c,1,1,f2);
      fread((void *)&c,1,1,f) ;}
    printf("\n");
    fclose(f);
    fclose(f2); }
}

static char names[500][100] ;

void main(int argc,char **argv) {
  struct _finddata_t c_file;
  long hFile;
  int i = 0 ;
  char path[500];
  char fichier[500];
  strcpy(path,argv[1]);
  //strcat(path,"\\*.cpp");
  printf("%s\n",path);
  if ( (hFile = _findfirst(path,&c_file)) != -1L ) {
    strcpy(names[i],c_file.name);
    i++;
    while( _findnext(hFile,&c_file) == 0 ) {
      strcpy(names[i],c_file.name);
      i++; }
    _findclose( hFile ); }
  printf("%d fichiers\n",i);
  for ( int j = 0 ; j < i ; j++ ) {
  //  strcpy(fichier,argv[1]);
  //  strcat(fichier,"\\");
    strcpy(fichier,names[j]);
    traiteFichier(fichier) ;}
}
