I am trying to figure out that if we use
eeprom_write_block function or
eeprom_update_block function do we need to manually null terminate it?
I came across this tutorial on avr-freaks where in one comment it is said that you have to read the strings and null terminate them but there is no word about writing. Couldnt get anything the avr-libc manual as well.
I have reserved some parts of eeprom using
EEMEM and they are strings. I am not sure how long the string would be except that it would be smaller than a max value. Now When I would read the string back from the eeprom I would just be reading the maximum number of bytes as again I would have no idea of the size of the string. If the eeprom has a null value at the end of the string when writing to it, the read string will have that null at the correct place.
I am saving mobile numbers of users as:
uint8_t EEMEM users[numberOfUsers][maxChar4Number];
Now when I get a number parsed and then save it to eeprom
#define eepu(message, EEADDR, BLKSIZE) eeprom_update_block((const void *)message, (void *)EEADDR, BLKSIZE); eepu(user, users, strlen(user)); //strlen(user) will be less than the maxChar4Number
This will write the number to eeprom. When I read the i would be reading maxChar4Number bytes and a number could have been shorter than that length.