AnsweredAssumed Answered

How I can write a EOF?

Question asked by nico engel on May 31, 2012
Latest reply on Nov 15, 2012 by Martin Kojtal



I initialize the io-driver for memory with this code. That works well:



uint8_t memory [4000]; uint32_t mem_init (void){    MQX_FILE_PTR    drive_p        = NULL;    _mqx_uint       error_code      = 0;     if ( (error_code = _io_mem_install(NAME_OF_FILE, memory, sizeof(memory))) == MQX_OUT_OF_MEMORY)                               {                                               printf("could not install drive\n");                                               return 1;                               }     //!____Open_the_drive______________________________________________________    drive_p = _io_fopen( NAME_OF_FILE, "r");    if (drive_p == NULL )    {        printf("unable to open %s\n", NAME_OF_FILE);        return 1;    }   //!___close________________________________________________________________    _io_fclose(drive_p);    return 0;}




After that, I open again with:

pDataFile  = fopen(NAME_OF_FILE, "w+");



and write some lines with:

fprintf(pDataFile, "%s\n", buffer);



Until this point everything works well. Now I read out all lines until the function “_io_fgetline()” receive “IO_EOF”. But I get much more (empty) lines as I have written before.


Why the driver does not set the EOF automatically?

Can I set explicit the “End Of File”?


Thank you for response.