Blame view

main.c 1.92 KB
00160129   rsSimonin   creation main.c
1
2
3
4
5
6
  #include <stdio.h>
  #include <stdlib.h>
  #include <stdbool.h>
  #include <string.h>
  #include "arbre.h"
  
35bdc271   rsimonin   affichage
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  int main (int argc,char *argv[]){
      system("clear");
      FILE* dico = NULL;
      printf("==============================================\n");
      if(argc >1){
          printf("chargement de votre dictionnaire \n");
          printf("nom: %s\n",argv[1]);
          dico=fopen(argv[1],"r"); 
      }
  //     else dico=fopen("words-no-accents","r");
      
    	if(dico == NULL){
  //         return EXIT_FAILURE;
          printf("chargement du dictionnaire par default\n");
          printf("nom du dico: words-no-accents\n");
          dico=fopen("words-no-accents","r");
      } //File is not readable
    	
00160129   rsSimonin   creation main.c
25
      struct dico *mondico=malloc(sizeof(struct dico));
35bdc271   rsimonin   affichage
26
27
28
29
30
31
32
33
34
35
36
37
      charger_dico(dico,&mondico);
  //     affiche_dico(mondico);
      fclose(dico); 
      printf("==============================================\n\n\n");
      
      
      
      char mot[]="zombie";
      char mot2[]="chaine";
      mot_existe(mondico->alpha[calculcase('r')],"rerere",0);
      mot_existe(mondico->alpha[calculcase(mot[0])],mot,0);
      mot_existe(mondico->alpha[calculcase(mot2[0])],mot2,0);
00160129   rsSimonin   creation main.c
38
      
35bdc271   rsimonin   affichage
39
40
  //     printf("1: %s:%d \n",mot,mot_existe(mondico->alpha[calculcase(mot[0])],mot,0));
  //     printf("2: %s:%d \n",mot2,mot_existe(mondico->alpha[calculcase(mot2[0])],mot2,0));
00160129   rsSimonin   creation main.c
41
      
35bdc271   rsimonin   affichage
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
      FILE* fichier_utilisateur = NULL;
      if(argc >2){
          printf("Analyse de votre fichier \n");
          fichier_utilisateur=fopen(argv[2],"r"); 
          printf("Fin Analyse de votre fichier \n");
      }
      
       if (fichier_utilisateur!=NULL){
          printf("analyse en cours\n");
           int juste=0;
           int faux=0;
           analyse_fichier(fichier_utilisateur,mondico,&juste,&faux);
           printf("juste:%d \n",juste);
           printf("faux:%d \n",faux);
       }
      
      printf("fin programme \n");
00160129   rsSimonin   creation main.c
59
      free_dico(mondico);
35bdc271   rsimonin   affichage
60
61
62
63
      if (fichier_utilisateur!=NULL){
          fclose(fichier_utilisateur);
      }
             
00160129   rsSimonin   creation main.c
64
65
      return 0;
  }