How can I read multiple bytes into a single variable of these types?
use a pointer to read each byte of a multi-byte type and save it into eeprom;
then do the same in reading them back: use a pointer to re-assemble the data (in bytes).
sizeof() comes in handy here.
Edit: lots of wonderfully complex answers for something this simple. When I get sometime I will pin my approach down.
Btw, many i2c libraries allow blocked read or write. So take that into your coding consideration.
edit2:
so here is what I have, to demonstrate how pointers can be used to write / read data.
//simulated write to buffer
//write n bytes of data from *ptr to address starting with addr
void mem_write(char addr, char *ptr, char n) {
do {buffer[addr++] = *ptr++;} while (n--);
}
//simulated read from buffer
void mem_read(char addr, char *ptr, char n) {
do {*ptr++ = buffer[addr++];} while (n--);
}
in this particular example, mem_write() writes n bytes of data, from source pointer ptr, into buffer[] starting at address addr. the read does the same.
you can port in your i2c byte read / write routines here, or use block read/write routines for more efficiency.
to confirm that it works, I wrote the following:
void setup() {
Serial.begin(9600); //initialize serial transmission
dat.x = 1; dat.z = 3.0; //initialize dat
dat_ptr = (uint8_t *)&dat; //initialize pointers
dat_ptr1= (uint8_t *)&dat1;
//print serial
Serial.print("line 0: size = "); Serial.print(sizeof dat); Serial.print(", x = "); Serial.print(dat.x); Serial.print(", z = "); Serial.println(dat.z);
//round 1: similated eeprom write/read
mem_write(0, dat_ptr, sizeof dat); //write to buffer
dat1.x = 0; dat1.z = 0; //initialize dat1
mem_read(0, dat_ptr1, sizeof dat1); //read from buffer
//now, dat1 contains the same data as dat
//print dat1 on serial -> it should read identical to line 0
Serial.print("line 1: size = "); Serial.print(sizeof dat1); Serial.print(", x = "); Serial.print(dat1.x); Serial.print(", z = "); Serial.println(dat1.z);
//round 2: similated eeprom write/read
//slightly different way of doing the same
dat.x +=1; dat.z +=10.0; //x=2, z=13.0
mem_write(0, (char *)&dat, sizeof dat); //write to buffer
dat1.x = 0; dat1.z = 0; //initialize dat1
mem_read(0, (char *)&dat1, sizeof dat1); //read from buffer
//now dat1.x = 1+1=2, dat1.z = 3.0+10.0 = 13.0
//print dat1 on serial
Serial.print("line 2: size = "); Serial.print(sizeof dat1); Serial.print(", x = "); Serial.print(dat1.x); Serial.print(", z = "); Serial.println(dat1.z);
}
it essentially writes one data element "dat" into the buffer, and read it back into "dat1"; both items are printed over serial to confirm that the write / read are successful.
then I incremented on dat, and wrote it to buffer and read it back to dat1. again, printed dat1 on the serial monitor to confirm that we have the right result.
here is what I got:

so we have the expected result.
the approach here is fairly standard. Obviously, experts usually come up with far more complex ways of doing simple things, as shown earlier answers, :)