DEV/DEV1.1/TP12/compteur.c

17 lines
270 B
C
Raw Normal View History

2022-11-29 11:21:49 +01:00
#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;
}