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
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
FILE * fichier;
int chaine[30],mot,i;
i=0;
fichier = fopen("dico.txt","r"); // ouverture et lecture du .txt
if(fichier==0)
{
printf("Erreur ouverture fichier !\n\n"); // verif du fopen
system ("pause");
return -1;
}
else
{
mot=rand()% (249643+1); // tirage aléatoire sur 249643 mots, 1 mot par ligne
while (i<=mot)
{
fgets(chaine,30,fichier);
i++;
}
printf ("Le mot choisi est : %d",mot);
fclose(fichier);
}
system("pause");
return 0;
} |
Partager