DEV/DEV1.1/TP12/compteur.c

17 lines
270 B
C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char const *argv[])
{
FILE *f;
f=fopen("compteur.txt","r");
int n = 0;
fread(&n,1,1,f);
n++;
f=fopen("compteur.txt","w");
fwrite(&n,1,1,f);
fclose(f);
printf("%d\n", n);
return 0;
}