principal
Dependencies: mbed fastlib vga640x400
FICHIER/fonctionFichier.cpp@2:05fe3543a781, 2019-06-13 (annotated)
- Committer:
- yokoland95
- Date:
- Thu Jun 13 15:56:16 2019 +0000
- Revision:
- 2:05fe3543a781
blabla
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yokoland95 | 2:05fe3543a781 | 1 | #include "mbed.h" |
yokoland95 | 2:05fe3543a781 | 2 | #include "fichier.h" |
yokoland95 | 2:05fe3543a781 | 3 | |
yokoland95 | 2:05fe3543a781 | 4 | |
yokoland95 | 2:05fe3543a781 | 5 | |
yokoland95 | 2:05fe3543a781 | 6 | /*-------------------------------------------*/ |
yokoland95 | 2:05fe3543a781 | 7 | /* COMPTE LE NOMBRE DE LIGNE DANS LE FICHIER */ |
yokoland95 | 2:05fe3543a781 | 8 | /*-------------------------------------------*/ |
yokoland95 | 2:05fe3543a781 | 9 | int nombre_ligne_fichier(FILE* fp){ |
yokoland95 | 2:05fe3543a781 | 10 | int total = 0; |
yokoland95 | 2:05fe3543a781 | 11 | char ligne[500]; |
yokoland95 | 2:05fe3543a781 | 12 | rewind(fp); |
yokoland95 | 2:05fe3543a781 | 13 | |
yokoland95 | 2:05fe3543a781 | 14 | while ( fgets(ligne, 500, fp) != NULL){ |
yokoland95 | 2:05fe3543a781 | 15 | total++;; |
yokoland95 | 2:05fe3543a781 | 16 | } |
yokoland95 | 2:05fe3543a781 | 17 | rewind(fp); |
yokoland95 | 2:05fe3543a781 | 18 | return total; |
yokoland95 | 2:05fe3543a781 | 19 | } |
yokoland95 | 2:05fe3543a781 | 20 | |
yokoland95 | 2:05fe3543a781 | 21 | /*-----------------------------------*/ |
yokoland95 | 2:05fe3543a781 | 22 | /* RETOURNE LE CONTENU DE LA LIGNE X */ |
yokoland95 | 2:05fe3543a781 | 23 | /*-----------------------------------*/ |
yokoland95 | 2:05fe3543a781 | 24 | void retourne_ligne(int num, char ligne[500], FILE* fp){ |
yokoland95 | 2:05fe3543a781 | 25 | int cmpt = 1; |
yokoland95 | 2:05fe3543a781 | 26 | rewind(fp); |
yokoland95 | 2:05fe3543a781 | 27 | |
yokoland95 | 2:05fe3543a781 | 28 | fgets(ligne, 500, fp); |
yokoland95 | 2:05fe3543a781 | 29 | |
yokoland95 | 2:05fe3543a781 | 30 | while( cmpt != num){ |
yokoland95 | 2:05fe3543a781 | 31 | fgets(ligne, 500, fp); |
yokoland95 | 2:05fe3543a781 | 32 | cmpt++; |
yokoland95 | 2:05fe3543a781 | 33 | } |
yokoland95 | 2:05fe3543a781 | 34 | |
yokoland95 | 2:05fe3543a781 | 35 | rewind(fp); |
yokoland95 | 2:05fe3543a781 | 36 | return; |
yokoland95 | 2:05fe3543a781 | 37 | |
yokoland95 | 2:05fe3543a781 | 38 | } |
yokoland95 | 2:05fe3543a781 | 39 | |
yokoland95 | 2:05fe3543a781 | 40 | char* retourne_element_ligne(int num, char ligne[500]){ |
yokoland95 | 2:05fe3543a781 | 41 | int cmpt = 1; |
yokoland95 | 2:05fe3543a781 | 42 | char *element; |
yokoland95 | 2:05fe3543a781 | 43 | char stock[500]; |
yokoland95 | 2:05fe3543a781 | 44 | |
yokoland95 | 2:05fe3543a781 | 45 | strcpy(stock, ligne); |
yokoland95 | 2:05fe3543a781 | 46 | element = strtok(stock, ";"); |
yokoland95 | 2:05fe3543a781 | 47 | //printf ("stock : %s\n\r", element); |
yokoland95 | 2:05fe3543a781 | 48 | while( cmpt != num){ |
yokoland95 | 2:05fe3543a781 | 49 | element = strtok( NULL, ";"); |
yokoland95 | 2:05fe3543a781 | 50 | cmpt++; |
yokoland95 | 2:05fe3543a781 | 51 | //printf ("stock : %s\n\r", element); |
yokoland95 | 2:05fe3543a781 | 52 | element = element; |
yokoland95 | 2:05fe3543a781 | 53 | } |
yokoland95 | 2:05fe3543a781 | 54 | return element; |
yokoland95 | 2:05fe3543a781 | 55 | } |
yokoland95 | 2:05fe3543a781 | 56 | |
yokoland95 | 2:05fe3543a781 | 57 | int num_bonne_reponse( char ligne[500]){ |
yokoland95 | 2:05fe3543a781 | 58 | char* element; |
yokoland95 | 2:05fe3543a781 | 59 | int reponse; |
yokoland95 | 2:05fe3543a781 | 60 | element = retourne_element_ligne(6, ligne); |
yokoland95 | 2:05fe3543a781 | 61 | reponse = atoi( element ); |
yokoland95 | 2:05fe3543a781 | 62 | return reponse; |
yokoland95 | 2:05fe3543a781 | 63 | } |