Can't read float from file with fscanf()

I’m using LittleFileSystem and want to write and read a float from a txt file.

FILE *f = fopen("/fs/numbers.txt", "r+");
float number = 12.12f;
// Store number
fprintf(f, "%f\n", number);
// close file and reopen
float c;
    while (!feof(f)) {
        fscanf(f, "%f\n", &c);
        printf("number: %f", c);

But I couldn’t get float c’s value from file, in terminal I only got this:


I wonder why float value can’t be read correctly


Maybe there is not problem with read but with write, try to look at this - mbed-os/platform/source/minimal-printf at master · ARMmbed/mbed-os · GitHub

BR, Jan