From 1e85143fa475be493d595b780012d45e0ce242c1 Mon Sep 17 00:00:00 2001 From: rsimonin Date: Sat, 13 Apr 2019 11:01:31 +0200 Subject: [PATCH] modif_affichage --- main.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 63 insertions(+), 18 deletions(-) diff --git a/main.c b/main.c index 075dc7d..f32e3ca 100644 --- a/main.c +++ b/main.c @@ -6,56 +6,101 @@ int main (int argc,char *argv[]){ system("clear"); + printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); + printf("\nBonjour et bienvenue dans le projet de Programmation Avancée IMA 3\n\n"); + printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n"); + + printf("\nAppuyez sur ENTREE pour continuer...\n"); + getchar(); + FILE* dico = NULL; - printf("==============================================\n"); + char mot_dico[20]; //opti + char mot_fichier[20]; + + + if(argc <2){ + + printf("Vous n'avez pas entrée de dictionnaire ainsi que de fichier\n"); + printf("Veuillez entrez votre nom de dictionnaire\n"); + scanf("%s",mot_dico); + printf("\n\n"); + printf("Veuillez entrez votre nom de fichier\n"); + scanf("%s",mot_fichier); + printf("\n\n"); + } + else if(argc <3){ + printf("Vous n'avez pas entrée de fichier\n"); + printf("Veuillez entrez votre nom de fichier\n"); + scanf("%s",mot_fichier); + printf("\n\n"); + } + + printf("==================================================================\n"); if(argc >1){ printf("chargement de votre dictionnaire \n"); printf("nom: %s\n",argv[1]); dico=fopen(argv[1],"r"); } + else { + printf("chargement de votre dictionnaire \n"); + printf("nom: %s\n",mot_dico); + dico=fopen(mot_dico,"r"); + } // else dico=fopen("words-no-accents","r"); if(dico == NULL){ -// return EXIT_FAILURE; - printf("chargement du dictionnaire par default\n"); + printf("Nous avons pas compris votre demande.\nNous vous chargeons le 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"); - - + 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("\nAppuyez sur ENTREE pour continuer...\n"); + getchar(); + getchar(); + // 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; + printf("##################################################################\n"); if(argc >2){ - printf("Analyse de votre fichier \n"); + printf("Ouverture de votre fichier: %s \n",argv[2]); fichier_utilisateur=fopen(argv[2],"r"); - printf("Fin Analyse de votre fichier \n"); + printf("Fermeture de votre fichier \n"); + } + else { + printf("Ouverture de votre fichier: %s \n",mot_fichier); + fichier_utilisateur=fopen(mot_fichier,"r"); + printf("Fermeture de votre fichier \n"); + } + if (fichier_utilisateur==NULL){ + printf("Nous avons pas reussi à ouvrir le fichier\n"); } + printf("##################################################################\n"); + printf("\nAppuyez sur ENTREE pour continuer...\n"); + getchar(); if (fichier_utilisateur!=NULL){ - printf("analyse en cours\n"); + printf("\n\n¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤\n"); + printf("analyse en cours\n\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("Votre fichier contient %d de mots, dont %d justes et %d faux.\n",juste+faux,juste,faux); + printf("¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤\n"); + printf("\nAppuyez sur ENTREE pour continuer...\n"); + getchar(); } - printf("fin programme \n"); + printf("\n\n\nLe programme est fini, vous pouvez relancer une execution\nCommande: ./executable NOM-DICO NOM-FICHIER\n\nA bientôt\n"); free_dico(mondico); if (fichier_utilisateur!=NULL){ fclose(fichier_utilisateur); -- libgit2 0.21.2