Beruflich Dokumente
Kultur Dokumente
Page 1 sur 15
1 #include <stdlib.h>
2 #include <stdio.h>
https://openclassrooms.com/courses/apprenez-a-programmer-en-c/lire-et-ecrire-dans-...
16/12/2015
Page 2 sur 15
https://openclassrooms.com/courses/apprenez-a-programmer-en-c/lire-et-ecrire-dans-...
16/12/2015
Page 3 sur 15
https://openclassrooms.com/courses/apprenez-a-programmer-en-c/lire-et-ecrire-dans-...
16/12/2015
Page 4 sur 15
https://openclassrooms.com/courses/apprenez-a-programmer-en-c/lire-et-ecrire-dans-...
16/12/2015
Page 5 sur 15
https://openclassrooms.com/courses/apprenez-a-programmer-en-c/lire-et-ecrire-dans-...
16/12/2015
Page 6 sur 15
1 fclose(fichier);
ui a t ouvert
criture
https://openclassrooms.com/courses/apprenez-a-programmer-en-c/lire-et-ecrire-dans-...
16/12/2015
Page sur 15
fputc
fputs
https://openclassrooms.com/courses/apprenez-a-programmer-en-c/lire-et-ecrire-dans-...
16/12/2015
Page sur 15
vous
", fichier);
fpr!!tf
https://openclassrooms.com/courses/apprenez-a-programmer-en-c/lire-et-ecrire-dans-...
16/12/2015
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 }
Page sur 15
vous
");
ui utilise le programme, il a
d ans", age);
}
return 0;
f!!tc
https://openclassrooms.com/courses/apprenez-a-programmer-en-c/lire-et-ecrire-dans-...
16/12/2015
Page 10 sur 15
Coucou,
f!!ts
1 #define
ILLE M
1000 // ableau de taille 1000
2
3 int main(int argc, char *argv[])
https://openclassrooms.com/courses/apprenez-a-programmer-en-c/lire-et-ecrire-dans-...
16/12/2015
4 {
5
FILE* fichier = NULL;
6
char chaine[ ILLE M ] = ""; // Cha ne vide de taille
ILLE M
7
8
fichier = fopen("test.txt", "r");
9
10
if (fichier != NULL)
11
{
12
fgets(chaine,
ILLE M , fichier); // On lit maximum
ILLE M
le tout dans "chaine"
13
printf(" s", chaine); // On affiche la cha ne
14
15
fclose(fichier);
16
}
17
18
return 0;
19 }
Page 11 sur 15
Coucou,
1 #define
ILLE M
1000
2
3 int main(int argc, char *argv[])
4 {
5
FILE* fichier = NULL;
6
char chaine[ ILLE M ] = "";
7
8
fichier = fopen("test.txt", "r");
9
10
if (fichier != NULL)
11
{
12
hile (fgets(chaine,
ILLE M , fichier) != NULL) // On lit le fichier tant
d'erreur (NULL)
13
{
14
printf(" s", chaine); // On affiche la cha ne u'on vient de lire
15
}
16
17
fclose(fichier);
18
}
https://openclassrooms.com/courses/apprenez-a-programmer-en-c/lire-et-ecrire-dans-...
16/12/2015
19
20
21 }
Page 12 sur 15
return 0;
hile (fgets(chaine,
ILLE M
, fichier) != NULL)
fscanf
Se d
cer d n un fichier
https://openclassrooms.com/courses/apprenez-a-programmer-en-c/lire-et-ecrire-dans-...
16/12/2015
Page 13 sur 15
1 fsee (fichier,
4, SEE
SE );
CU );
END);
https://openclassrooms.com/courses/apprenez-a-programmer-en-c/lire-et-ecrire-dans-...
16/12/2015
Page 14 sur 15
Ren mmer et u
rimer un fichier
https://openclassrooms.com/courses/apprenez-a-programmer-en-c/lire-et-ecrire-dans-...
16/12/2015
Page 15 sur 15
https://openclassrooms.com/courses/apprenez-a-programmer-en-c/lire-et-ecrire-dans-...
16/12/2015