Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.88 KB | None | 0 0
  1. //
  2. //  main.c
  3. //  Exercice 2
  4. //
  5. //  Created by Malik Derkaoui on 18/10/2019.
  6. //  Copyright © 2019 Malik Derkaoui. All rights reserved.
  7. //
  8.  
  9. #include <stdio.h>
  10.  
  11.  
  12. void compte(int* min, int* maj){
  13.     char y;
  14.     *min = 0; *maj = 0;
  15.     FILE *f;
  16.     f = fopen("C:/temp/lettres.txt","r");
  17.     if (f != NULL)
  18.     {
  19.         while (!feof(f))
  20.         {
  21.             fscanf(f,"%c",&y);
  22.             if ((y <= 'z') && (y>= 'a'))
  23.             {
  24.                 (*min)++;
  25.             }
  26.             if ((y <= 'Z') && (y>= 'A'))
  27.             {
  28.                 (*maj)++;
  29.             }
  30.         }
  31.         fclose(f);
  32.     }
  33. }
  34. int main(int argc, const char * argv[]) {
  35.     int mini,maxi;
  36.     compte(&mini,&maxi);
  37.     if ( mini == -1 && maxi == -1)
  38.     {
  39.         printf("Erreur de fichier");
  40.     }
  41.     else{
  42.         printf("min = %d max = %d",mini,maxi);
  43.     }
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement