principal

Dependencies:   mbed fastlib vga640x400

Revision:
2:05fe3543a781
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FICHIER/exmain.cpp	Thu Jun 13 15:56:16 2019 +0000
@@ -0,0 +1,73 @@
+#include "mbed.h"
+#include "fichier.h"
+  
+ 
+LocalFileSystem local("local");             // Create the local filesystem under the name "local"
+ 
+int exmain() {
+    int i,j,nb;
+    /*
+    FILE *fp = fopen("/local/out.txt", "w");  // Open "out.txt" on the local file system for writing
+    fprintf(fp, "coucou clement World!");
+    fclose(fp);
+    //remove("/local/out.txt");                 // Removes the file "out.txt" from the local file system
+    */
+    
+    DIR *d = opendir("/local");               // Opens the root directory of the local file system
+    struct dirent *p;
+    while((p = readdir(d)) != NULL) {         // Print the names of the files in the local file system
+      printf("%s\n\r", p->d_name);              // to stdout.
+    }
+    closedir(d);
+
+
+    FILE *fp = fopen("/local/form.csv", "r"); 
+    if(!fp) { 
+        error("Could not open file!\n\r");
+    }
+    
+    
+    char ligne[500];
+    char* morceau;
+    /*-------------------------------------------*/ 
+    /* COMPTE LE NOMBRE DE LIGNE DANS LE FICHIER */
+    /*-------------------------------------------*/ 
+    printf("nombre de ligne %d\n\r", nb = nombre_ligne_fichier(fp));
+    
+    for( i = 2; i <= nb; i++){     
+        /*-----------------------------------*/ 
+        /* RETOURNE LE CONTENU DE LA LIGNE X */
+        /*-----------------------------------*/ 
+        retourne_ligne(i,ligne,fp);
+        printf("ligne %d est %s\n\r",i,ligne);
+    
+        /*-----------------------------------*/ 
+        /* RETOURNE L'ÉLÉMENT X DE LA LIGNE  */
+        /*-----------------------------------*/ 
+        morceau = retourne_element_ligne(1, ligne);
+        printf("la question est: %s \n\r", morceau);
+        
+        /*-----------------------------------*/ 
+        /* RETOURNE L'ÉLÉMENT X DE LA LIGNE  */
+        /*-----------------------------------*/ 
+        for(j = 1; j < 5; j++){
+            morceau = retourne_element_ligne(j+1, ligne);
+            printf("Reponse %d: %s \n\r",j, morceau);
+        }
+    
+        /*----------------------------------------*/ 
+        /* RETOURNE LA BONNE REPONSE DE LA LIGNE  */
+        /*----------------------------------------*/     
+        j = num_bonne_reponse(ligne);
+        morceau = retourne_element_ligne(j+1, ligne);
+        printf("bonne reponse est la %d: %s \n\r",j, morceau);
+    
+        /*-----------------------------------*/ 
+        /* RETOURNE L'ÉLÉMENT X DE LA LIGNE  */
+        /*-----------------------------------*/ 
+        morceau = retourne_element_ligne(7, ligne);
+        printf("la raison: %s \n\r", morceau);
+    }
+    fclose(fp);
+    
+}
\ No newline at end of file