RL-ARM Filesystem problem using feof

Hi,

I'am using RL ARM Flash Filesystem V3.13 on Atmel AT91SAM7S256 processor.
In the following example Reading a File (with 3 characters) the feof function reads everytime 4 characters.

here is my test programm:

void TestFsEof(void)    {
#define FNAME   "F:Tst.bin"
FILE *fout, *fin;

        // Write
        fout = fopen (FNAME, "w");
        if (fout != NULL)
        {       char Car = 'A';
                for (int cnt=0;  cnt<3;  cnt++)
                {       fwrite (&Car, sizeof(Car), 1, fout);
                        Car++;
                }
                fclose (fout);
        }


        fin = fopen (FNAME, "r");
        if (fin != NULL)
        {       int RecNr = 0;
                char Car = 0;
                u32 Result;
                while (!feof (fin)) {
                        Result = fread (&Car, sizeof (Car), 1, fin);
                        //if (Result < 1)
                        //      break;  // Checking EOF does not work, so i must check the Result from fread()

                        TRACE(("\n\rRecNr:%d  Car:%c",  RecNr, Car ));
                        RecNr++;
                }
                fclose (fin);
        }
}

Thank you for any replies.
Eugen

More questions in this forum