Bonjour a tous

Pourquoi mon code ne trouve pas tout les voyelles qui se trouve dans mon texte ?


Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
   1. #include  <stdlib.h>
   2. #include <stdio.h>
   3. #define TAILLE_MAX 1000
   4.
   5.
   6. int main(int argc, char *argv[])
   7. {
   8.
   9. char voy[6] = {'a','e','i','o','u','y'};
  10. int compte[6] = {0}, i;
  11. FILE* fichier = NULL;
  12. char chaine[TAILLE_MAX] = "";
  13.
  14.    if ((fichier = fopen("test.txt", "r" )) != NULL)
  15. {
  16.          while (fgets(chaine, TAILLE_MAX, fichier) != NULL) // On lit le fichier tant qu'on ne reçoit pas d'erreur (NULL)
  17.           {
  18.              for(i = 0; i < 6; i++)
  19.              if(chaine[i] == voy[i])
  20.              compte[i] = compte[i] + 1; // On affiche la chaîne qu'on vient de lire
  21.           }
  22.
  23.     printf("Votre texte comporte :\n" );
  24.     for(i = 0; i < 6; i++)
  25.     printf("%d fois la lettre %c\n", compte[i], voy[i]);
  26.
  27.     fclose(fichier);
  28. }
  29.
  30.   return 0;
  31. }