update
This commit is contained in:
21
DEV.1.1/Fichiers/lecture-ficher/openfile-fgetc.c
Normal file
21
DEV.1.1/Fichiers/lecture-ficher/openfile-fgetc.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void){
|
||||
FILE *fic = fopen("text.txt", "r");
|
||||
int lettre = 0;
|
||||
|
||||
if(fic == NULL){
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while((lettre = fgetc(fic)) != EOF){
|
||||
printf("%c", lettre);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
fclose(fic);
|
||||
|
||||
return 0;
|
||||
}
|
21
DEV.1.1/Fichiers/lecture-ficher/openfile-fgets.c
Normal file
21
DEV.1.1/Fichiers/lecture-ficher/openfile-fgets.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void){
|
||||
FILE *fic = fopen("text.txt", "r");
|
||||
char lettre[256];
|
||||
|
||||
if(fic == NULL){
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while(fgets(lettre, 255, fic) != NULL){
|
||||
printf("%s", lettre);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
fclose(fic);
|
||||
|
||||
return 0;
|
||||
}
|
23
DEV.1.1/Fichiers/lecture-ficher/openfile-fscanf.c
Normal file
23
DEV.1.1/Fichiers/lecture-ficher/openfile-fscanf.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void){
|
||||
FILE *fic = fopen("text.txt", "r");
|
||||
char texte[256];
|
||||
int age = 0;
|
||||
int Nombre = 0;
|
||||
|
||||
if(fic == NULL){
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fscanf(fic, "%s %d %d", texte, &age, &Nombre);
|
||||
printf("Nom : %s\n", texte);
|
||||
printf("Age : %d\n", age);
|
||||
|
||||
printf("\n");
|
||||
|
||||
fclose(fic);
|
||||
|
||||
return 0;
|
||||
}
|
2
DEV.1.1/Fichiers/lecture-ficher/text.txt
Normal file
2
DEV.1.1/Fichiers/lecture-ficher/text.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Emmanuel 18 1000
|
||||
Toto 47 365
|
Reference in New Issue
Block a user