principal
Dependencies: mbed fastlib vga640x400
FICHIER/fonctionFichier.cpp
- Committer:
- yokoland95
- Date:
- 2019-06-13
- Revision:
- 2:05fe3543a781
File content as of revision 2:05fe3543a781:
#include "mbed.h" #include "fichier.h" /*-------------------------------------------*/ /* COMPTE LE NOMBRE DE LIGNE DANS LE FICHIER */ /*-------------------------------------------*/ int nombre_ligne_fichier(FILE* fp){ int total = 0; char ligne[500]; rewind(fp); while ( fgets(ligne, 500, fp) != NULL){ total++;; } rewind(fp); return total; } /*-----------------------------------*/ /* RETOURNE LE CONTENU DE LA LIGNE X */ /*-----------------------------------*/ void retourne_ligne(int num, char ligne[500], FILE* fp){ int cmpt = 1; rewind(fp); fgets(ligne, 500, fp); while( cmpt != num){ fgets(ligne, 500, fp); cmpt++; } rewind(fp); return; } char* retourne_element_ligne(int num, char ligne[500]){ int cmpt = 1; char *element; char stock[500]; strcpy(stock, ligne); element = strtok(stock, ";"); //printf ("stock : %s\n\r", element); while( cmpt != num){ element = strtok( NULL, ";"); cmpt++; //printf ("stock : %s\n\r", element); element = element; } return element; } int num_bonne_reponse( char ligne[500]){ char* element; int reponse; element = retourne_element_ligne(6, ligne); reponse = atoi( element ); return reponse; }