From 16e67e7ee00ce5cb3d029758f1dd74f38d7c1464 Mon Sep 17 00:00:00 2001 From: Thorsieger Date: Wed, 1 May 2019 20:19:33 +0200 Subject: [PATCH] l'utilisateur peut choisir les fichiers de dico et a tester --- american-english | 2 +- dico_test | 11 ++++++++++- main.c | 63 +++++++++++++++++++++++++++++++++++++++++---------------------- tree.c | 6 +++--- 4 files changed, 55 insertions(+), 27 deletions(-) diff --git a/american-english b/american-english index 3f9b27f..5593505 100644 --- a/american-english +++ b/american-english @@ -99168,4 +99168,4 @@ zygotes épées étude étude's -études +études \ No newline at end of file diff --git a/dico_test b/dico_test index 3e93355..e1d891d 100644 --- a/dico_test +++ b/dico_test @@ -1 +1,10 @@ -Although testing can determine the correctness of software under the assumption of some specific hypotheses (see the hierarchy of testing difficulty below), testing cannot identify all the defects within the software. Instead, it furnishes a criticism or comparison that compares the state and behavior of the product against test oracles principles or mechanisms by which someone might recognize a problem. These oracles may include (but are not limited to) specifications, contracts, comparable products, past versions of the same product, inferences about intended or expected purpose, user or customer expectations, relevant standards, applicable laws, or other criteria. 111 \ No newline at end of file +Sandra and Betty are sitting in the park, Sandra asks Betty:' Tell me about your family' + + + +Betty:' My family is a rather small one, with only three people, my father, my mother and me. My father is a doctor. My mother is a middle-school teacher. I am still a student. My mother is very gentle and soft while my father is a little bit hot-tempered. We love each other very much. Although sometimes we might become angry at one another, very soon we will forget the unpleasant things. We're a happy family, how about you?' + + + +Sandra:' I have a big family with seven people, my grandparents, parents, two brothers and me. We take care of one another, share housework, and often communicate all together.' + diff --git a/main.c b/main.c index 3ee226c..65f2040 100644 --- a/main.c +++ b/main.c @@ -3,32 +3,51 @@ int main() { setlocale(LC_ALL, ""); - FILE* fp = fopen("american-english","r"); - FILE* fp2 = fopen("dico_test","r"); - - if(fp == NULL) return 1 ; //File is not readable - - dico Dico; + //Récupération du fichier contenant le dictionnaire + char fichier[100]; + FILE* fp = NULL; + printf("Quel fichier voulez-vous utiliser comme dictionnaire ?\n"); + do{ + scanf("%s",fichier); + fp = fopen(fichier,"r"); + if(fp == NULL) + { + printf("Le fichier n'est pas accessible !\nEntrez un autre nom de fichier :\n"); + } + }while(fp == NULL); + + //Chargement du dictionnaire + dico Dico; init_dico(&Dico); - load_dico(fp,&Dico);//chargement de l'arbre - - printf("Loading done!\n"); - - - int result = find_erreur(Dico,fp2); - printf("%d\n",result); - - /*wchar_t mot[50]; - wscanf(L"%ls",mot); - int result; - result = find_mot(Dico,mot); - printf("%d\n",result);*/ + load_dico(fp,&Dico); + fclose(fp); + printf("Chargement du dictionnaire effectué!\n\n"); + + //Récupération du fichier contenant les mots à tester +char recommencer = ' '; + do{ + FILE* fp = NULL; + printf("Quel fichier voulez-vous tester ?\n"); + do{ + scanf("%s",fichier); + fp = fopen(fichier,"r"); + if(fp == NULL) + { + printf("Le fichier n'est pas accessible !\nEntrez un autre nom de fichier :\n"); + } + }while(fp == NULL); + + //Vérification des mots du fichier + int result = find_erreur(Dico,fp); + printf("Le fichier testé contient %d mots qui ne sont pas présent dans le dictionnaire.\n",result); + fclose(fp); + printf("Voulez vous tester un autre fichier ?[Y]\n"); + scanf(" %c",&recommencer); + }while(recommencer == 'Y' || recommencer == 'y'); - free_dico(Dico);//libérer la mémoire - fclose(fp); - fclose(fp2); + free_dico(Dico);//libérer la mémoire du dictionnaire printf("Fin du programme\n"); diff --git a/tree.c b/tree.c index 49cd757..24f0660 100644 --- a/tree.c +++ b/tree.c @@ -102,7 +102,7 @@ void splitcarac(dico *Dico,wchar_t message[]) void load_dico(FILE *fp, dico *Dico) { - wchar_t val[50]; + wchar_t val[3000]; while(fwscanf(fp, L"%ls",val)==1) { @@ -147,7 +147,7 @@ int find_mot(dico Dico,wchar_t mot[]) return 0; } if(mot[0]>='0' && mot[0]<='9')return 0; - + int fl =-1; if(mot[0]>='a' && mot[0]<='z') { @@ -191,7 +191,7 @@ int find_mot(dico Dico,wchar_t mot[]) int find_erreur(dico Dico, FILE *fp) { - wchar_t val[5000]; + wchar_t val[3000]; int cpt_erreur =0; while(fwscanf(fp, L"%ls",val)==1) -- libgit2 0.21.2