-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTP 9 (les fichiers).c
More file actions
66 lines (44 loc) · 1.67 KB
/
Copy pathTP 9 (les fichiers).c
File metadata and controls
66 lines (44 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
/* LES FONCTIONS DE LA MANIULATION DES FICHIERS
a-déclaration d'un fichier : FILE *<fichier>;
b-l'ouverture du fichier : <fichier>=fopen("nom de fichier","mode d'ouverture");
mode d'ouverture : "r"=> lire
"w"=> écrire
"a"=> ajouetr
c-l'ecriture dans un fichier: fwrite(&variable,sizeof(bloc),nbBloc,<fichier>); fichier binaire
fprintf(f,"%d",&variable); // // // texte
d-la lecture d'un fichier : fread(&variable,sizeof(bloc),nbBloc,<fichier>); fichier binaire
fscanf(f,"%d",&variable); // // // texte
e-tester la fin de fichier : feof(<fichier>));
f-la fermeture du fichier : fclose(<fichier>);
*/
void creation();
void display();
int main(int argc, char *argv[]) {
creation();
printf("ok,merci beaucoup.\n");
display();
getch();
return 0;
}
void creation(){
FILE *f; int x;
f=fopen("TP 9 essaye.txt","w");
do{
printf("donner un entier:");
scanf("%d",&x);
fprintf(f,"%d\n",x);
}while(x>0);
fclose(f);
}
void display(){
FILE *f; char caractere;
f=fopen("TP 9 essaye.txt","r");
while(!feof(f)){
caractere = fgetc(f);
printf("%c",caractere);
}
fclose(f);
}