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 78 79 80 81 82 83
|
include <windows.h>
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char *argv[])
{
FILE *fp;
int c;
int i;
int compteur = 0, limit = 0;
char s[256];
char u[256];
char t[256];
beginning:
fp = fopen ("dic.txt", "r");
while ((fgets (t, sizeof (t), fp) != NULL) && (limit < 3001))
{
limit++;
}
fseek (fp, 0L, SEEK_SET);
fclose (fp);
if (limit > 3000)
{
printf ("\nToo many words in the dictionnary ! \n");
printf ("Type q to quit or Enter to continue \n");
char answer = getchar ();
if (answer != 'q')
{
goto beginning;
}
}
else
{
fp = fopen ("dic.txt", "r");
limit = 0;
printf ("\nEnter your word : \n");
fgets (s, sizeof s, stdin);
while ((fgets (u, sizeof (u), fp) != NULL))
{
if ((strlen (s)) == (strlen (t)))
{
if (!strcasecmp (s, t))
{
printf ("mot exact");
break;
}
else
{
for (i = 0; i < strlen (t) - 1; i++)
{
if ((s[i] != t[i]) && (compteur < 2))
{
compteur++;
}
}
if (compteur == 1)
{
printf ("\n Proposition %s", t);
compteur = 0;
}
else
{
compteur = 0;
}
}
}
}
printf ("\n Type q to quit or Enter to continue \n");
char answer = getchar ();
if (answer != 'q')
{
goto beginning;
}
}
fclose (fp);
return 0;
} |
Partager