debut TP21
This commit is contained in:
BIN
DEV1.1/TP21/compte
Normal file
BIN
DEV1.1/TP21/compte
Normal file
Binary file not shown.
BIN
DEV1.1/TP21/compteur
Executable file
BIN
DEV1.1/TP21/compteur
Executable file
Binary file not shown.
24
DEV1.1/TP21/compteur.c
Normal file
24
DEV1.1/TP21/compteur.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void){
|
||||
int compteur;
|
||||
FILE* file;
|
||||
file=fopen("compte","r");
|
||||
if (file==NULL){
|
||||
printf("mauvaise ouverture");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
fread(&compteur,sizeof(int),1,file);
|
||||
printf("%d\n",compteur);
|
||||
fclose(file);
|
||||
fopen("compte","w");
|
||||
if (file==NULL){
|
||||
printf("mauvaise ouverture");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
compteur++;
|
||||
fwrite(&compteur,sizeof(int),1,file);
|
||||
fclose(file);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
BIN
DEV1.1/TP21/compteur.txt
Normal file
BIN
DEV1.1/TP21/compteur.txt
Normal file
Binary file not shown.
BIN
DEV1.1/TP21/init
Executable file
BIN
DEV1.1/TP21/init
Executable file
Binary file not shown.
11
DEV1.1/TP21/init.c
Normal file
11
DEV1.1/TP21/init.c
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void){
|
||||
int depart=0;
|
||||
FILE* file;
|
||||
file=fopen("compte","w");
|
||||
fwrite(&depart,sizeof(int),1,file);
|
||||
fclose(file);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user