Bonjour a tous j'aurai besoin d'aide concernant mon code. Dans ce petit programme je cherche a calculer la moyenne d'age des nom contenu dans un fichier texte. Je recupere d'abord l'age pour chaque ligne mais je ne sais pas comment calculer la moyenne.

voici mon code:

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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int main(void) {
FILE * fic;
char msg[20];
char *temp[6];
 
fic = fopen("f1.txt", "r");
 
int i=20;
int cpt=0;
int j=1;
 
while (i<151){
fseek( fic, i, SEEK_SET);
fgets( msg, 3, fic);
printf( "%s\n", msg);
i=i+26;
cpt=cpt++;
j++;
}
 
 
fclose(fic);
putchar('\n');
system("pause");
return 0;
}
Quelqu'un a-t-il une solution?
Merci d'avance.