main.c 1.92 KB
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include "arbre.h"

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
  	
    struct dico *mondico=malloc(sizeof(struct dico));
    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);
    
//     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));
    
    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");
    free_dico(mondico);
    if (fichier_utilisateur!=NULL){
        fclose(fichier_utilisateur);
    }
           
    return 0;
}