principal

Dependencies:   mbed fastlib vga640x400

Revision:
2:05fe3543a781
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FICHIER/fonctionFichier.cpp	Thu Jun 13 15:56:16 2019 +0000
@@ -0,0 +1,63 @@
+#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;
+    }
\ No newline at end of file