[Solved] How to read/write a Struct to NVRAM?

So I have a Struct defined like this:

struct Schedule {
  int duration;
  char date[5];
} schedule1, schedule2;

Schedule schedules[2] = {schedule1, schedule2};

I'm using RTClib to manage a DS1307 and I would like to write the struct (and later read) to the NVRAM it comes with. Is there a way to write / read the whole struct? Do I have to write field by field? If so, would it look like this?

rtc.writenvram(1, schedules[0].duration); // Write the duration starting at byte 1
rtc.writenvram(1 + sizeof(int), schedules[0].date, 5 * sizeof(char)); // Write date right next to duration?

Any help is appreciated.


The writenvram() function takes a pointer and a size

rtc.writenvram(0, (uint8_t *) (&(schedules[0])), sizeof(schedules[0]));

Doh! Thank you so much @blh64! I had tried

rtc.writenvram(0, (uint8_t) (schedules), sizeof(schedules));

and failed miserably. Looking at your solution made me see I was missing the * in the type casting! Now I can read and write properly.

Much obliged!