26 lines
505 B
C
26 lines
505 B
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <string.h>
|
||
|
|
||
|
int main(int argc, char const *argv[])
|
||
|
{
|
||
|
int time = 0;
|
||
|
FILE* f;
|
||
|
f=fopen("compteur","r");
|
||
|
if(f == NULL){
|
||
|
f=fopen("compteur","w");
|
||
|
fwrite(&time,1,4,f);
|
||
|
time = 1;
|
||
|
printf("Nombres de fois ouvert : inexistant\n");
|
||
|
fclose(f);
|
||
|
}
|
||
|
else{
|
||
|
fread(&time,1,4,f);
|
||
|
f=fopen("compteur","w");
|
||
|
time++;
|
||
|
fwrite(&time,1,4,f);
|
||
|
printf("Nombres de fois ouvert : %d\n", time);
|
||
|
fclose(f);
|
||
|
}
|
||
|
return 0;
|
||
|
}
|