Entrainements + fin TP structures
This commit is contained in:
45
DEV1.1/TP21/TP21_reponses.txt
Normal file
45
DEV1.1/TP21/TP21_reponses.txt
Normal file
@@ -0,0 +1,45 @@
|
||||
------ TP21 : Fichier ------
|
||||
|
||||
|
||||
1.
|
||||
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
FILE* fichier = NULL;
|
||||
int score;
|
||||
char caractere;
|
||||
char sigle[3];
|
||||
int resultat;
|
||||
int i;
|
||||
int lu;
|
||||
|
||||
fichier = fopen("top10", "r");
|
||||
if (fichier == NULL) {
|
||||
printf("Erreur d'ouverture.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
lu = fread(&resultat, sizeof(int), 1, fichier);
|
||||
for (i = 0; i != 3; i++) {
|
||||
lu = fread(&caractere, sizeof(char), 1, fichier);
|
||||
sigle[i] = caractere;
|
||||
}
|
||||
|
||||
while (lu == 1) {
|
||||
printf("%09d ", resultat);
|
||||
for (i = 0; i != 3; i++) {
|
||||
putchar(sigle[i]);
|
||||
}
|
||||
putchar('\n');
|
||||
lu = fread(&resultat, sizeof(int), 1, fichier);
|
||||
for (i = 0; i != 3; i++) {
|
||||
lu = fread(&caractere, sizeof(char), 1, fichier);
|
||||
sigle[i] = caractere;
|
||||
}
|
||||
}
|
||||
fclose(fichier);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
18
DEV1.1/TP21/test.c
Normal file
18
DEV1.1/TP21/test.c
Normal file
@@ -0,0 +1,18 @@
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
FILE* fichier = NULL;
|
||||
int score;
|
||||
char caractere;
|
||||
char sigle[3];
|
||||
int resultat;
|
||||
int i;
|
||||
int j = 0;
|
||||
int lu;
|
||||
char liste_sigles[10][3];
|
||||
int liste_resultats[10];
|
||||
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
BIN
DEV1.1/TP21/top10
Normal file
BIN
DEV1.1/TP21/top10
Normal file
Binary file not shown.
Reference in New Issue
Block a user