24 lines
523 B
C
24 lines
523 B
C
|
|
#include <stdio.h>
|
||
|
|
#include <stdlib.h>
|
||
|
|
|
||
|
|
int main(void){
|
||
|
|
int compteur;
|
||
|
|
FILE* file;
|
||
|
|
file=fopen("compte","r");
|
||
|
|
if (file==NULL){
|
||
|
|
printf("mauvaise ouverture");
|
||
|
|
return EXIT_FAILURE;
|
||
|
|
}
|
||
|
|
fread(&compteur,sizeof(int),1,file);
|
||
|
|
printf("%d\n",compteur);
|
||
|
|
fclose(file);
|
||
|
|
fopen("compte","w");
|
||
|
|
if (file==NULL){
|
||
|
|
printf("mauvaise ouverture");
|
||
|
|
return EXIT_FAILURE;
|
||
|
|
}
|
||
|
|
compteur++;
|
||
|
|
fwrite(&compteur,sizeof(int),1,file);
|
||
|
|
fclose(file);
|
||
|
|
return EXIT_SUCCESS;
|
||
|
|
}
|