APL/APL1.2/TP04/compteur.c

25 lines
332 B
C
Raw Permalink Normal View History

2021-11-30 15:06:27 +01:00
#include<stdio.h>
#include<stdlib.h>
int main(int argc, char * argv[]) {
FILE* flux = fopen("compte", "r");
int compte = 0;
if (flux) {
fread(&compte, 4, 1, flux);
}
compte++;
printf("%d\n", compte);
flux = fopen("compte", "w");
if (flux) {
fwrite(&compte, 4, 1, flux);
fclose(flux);
}
return EXIT_SUCCESS;
}