29 Novembre
This commit is contained in:
26
DEV1.1/TP13:Fichiers/Fichiers:suite/compteur.c
Normal file
26
DEV1.1/TP13:Fichiers/Fichiers:suite/compteur.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void) {
|
||||
int* n=malloc(4);
|
||||
FILE* f;
|
||||
f=fopen("nbrExec.txt","r");
|
||||
if(f!=NULL){
|
||||
fread(n,4,1,f);
|
||||
fclose(f);
|
||||
printf("Le code a ete executer %d fois.\n",*n);
|
||||
f=fopen("nbrExec.txt","w");
|
||||
*n=*n+1;
|
||||
fwrite(n,4,1,f);
|
||||
fclose(f);
|
||||
} else {
|
||||
*n=1;
|
||||
printf("Le code a ete executer %d fois.\n",*n);
|
||||
f=fopen("nbrExec.txt","w");
|
||||
*n=*n+1;
|
||||
fwrite(n,4,1,f);
|
||||
fclose(f);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user