1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
FILE *fichier=NULL;
int premierChoix=0, choixFin=0, nombreDeLettreDuMot=0, nombreDeLettreServant=0;
char motFrancais[100], motAnglaisEntre[100], motAnglaisCherche[100], motTrouve[100];
do
{
printf("Bienvenu dans ce programme de traduction Francais Anglais\n");
printf("Traduction de l'Anglais au Francais\nTapez 1\nDu Francais a l'Anglais\nTapez 2\n");
printf("Quel est vote choix?\n");
scanf("%ld",&premierChoix);
if(premierChoix==1)
{
printf("Veuillez entrer le mot Anglais: ");
scanf("%s", motAnglaisEntre);
nombreDeLettreDuMot = strlen(motAnglaisEntre);
printf("la chaine contient %s\n", motAnglaisEntre);
fichier=fopen("dicoANG.txt", "r");
if(fichier!=NULL)
{
while(fscanf(fichier, "%s", motAnglaisCherche)!=EOF)
{
nombreDeLettreServant=nombreDeLettreDuMot+1;
fseek(fichier, nombreDeLettreServant, SEEK_CUR);
}
fgets(motTrouve, 100, fichier);
printf("Traduction de %s en Francais= %s\n", motAnglaisEntre, motTrouve);
}
else
{
printf("Erreur d'ouverture de <dicoANG.txt>\n");
}
}
else if(premierChoix==2)
{
printf("Entrez le mot Francais: ");
scanf("%s", motFrancais);
nombreDeLettreDuMot = strlen(motFrancais);
printf("nombre de lettre:%ld\n", nombreDeLettreDuMot);
fichier=fopen("dicoFR.txt", "r");
if(fichier!=NULL)
{
fscanf(fichier, "%s", motFrancais);
nombreDeLettreServant=nombreDeLettreDuMot--;
fseek(fichier, nombreDeLettreServant, SEEK_CUR);
fgets(motTrouve, 100, fichier);
printf("Traduction de %s en Anglais= %s\n", motFrancais, motTrouve);
}
else
{
printf("Erreur d'ouverture de <dicoFR.txt>\n");
}
}
else
{
printf("Entrez un n° correct SVP\n");
}
printf("Voulez vous quitter?\1=OUI\n2=NON\n");
printf("Choix: ");
scanf("%ld",&choixFin);
}while(choixFin==2);
return 0;
} |