Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.c
- // Exercice 2
- //
- // Created by Malik Derkaoui on 18/10/2019.
- // Copyright © 2019 Malik Derkaoui. All rights reserved.
- //
- #include <stdio.h>
- void compte(int* min, int* maj){
- char y;
- *min = 0; *maj = 0;
- FILE *f;
- f = fopen("C:/temp/lettres.txt","r");
- if (f != NULL)
- {
- while (!feof(f))
- {
- fscanf(f,"%c",&y);
- if ((y <= 'z') && (y>= 'a'))
- {
- (*min)++;
- }
- if ((y <= 'Z') && (y>= 'A'))
- {
- (*maj)++;
- }
- }
- fclose(f);
- }
- }
- int main(int argc, const char * argv[]) {
- int mini,maxi;
- compte(&mini,&maxi);
- if ( mini == -1 && maxi == -1)
- {
- printf("Erreur de fichier");
- }
- else{
- printf("min = %d max = %d",mini,maxi);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement