Lecture d'un fichier pour récupération données

Dependencies:   mbed

Fork of LocalFileSystem_HelloWorld by mbed official

main.cpp

Committer:
LouisReynier
Date:
2017-06-22
Revision:
1:a5ed2347a210
Parent:
0:cc465aef98cf

File content as of revision 1:a5ed2347a210:

#include "mbed.h"
Serial pc(USBTX, USBRX); // tx, rx
LocalFileSystem local("local");               // Create the local filesystem under the name "local"
DigitalOut myled1(LED1);
DigitalOut myled2(LED2);

int main() {
    int tablo[6] = {0};
    int i = 0;
    myled1 = 1 ;
    myled1 = 0 ;
    printf("Debut programme \n");
    printf("Lecture des donnees \n");
    FILE *fp = fopen("/local/compil.txt", "r");  // Open "out.txt" on the local file system for writing
    for (i =0; i<6; i++)
    {
    fscanf(fp, "%d \n", &tablo[i]);
    }
    fclose(fp);
    // sortie sur moniteur
    printf("Donnees lues \n");
    myled1 = 0 ;
    for (i =0; i<6; i++)
    {
    printf("tablo[%d] = %d \n", i, tablo[i]);
    } 
    printf("Fin programme \n");
    myled2 = 1 ;
    
}