From 35bdc27170459aabd5d74607dafbe9de446b9469 Mon Sep 17 00:00:00 2001 From: rsimonin Date: Sat, 13 Apr 2019 09:35:48 +0200 Subject: [PATCH] affichage --- main.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/main.c b/main.c index fe0fa0a..075dc7d 100644 --- a/main.c +++ b/main.c @@ -4,17 +4,62 @@ #include #include "arbre.h" -int main () { - FILE* fp = fopen("words-no-accents","r"); //amelioration entrée - if(fp == NULL){ return EXIT_FAILURE;} //File is not readable - +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_arbre(fp,&mondico); - affiche_dico(mondico); + 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); - fclose(fp); + if (fichier_utilisateur!=NULL){ + fclose(fichier_utilisateur); + } + return 0; } - -- libgit2 0.21.2