Writing and Reading a 2D Array to EEPROM

Hi all.

Quite a simple question I feel, but I can't seem to work out the best way to do this.

I'd like to load a 2D array at startup, and save the array at the users discretion.

What would be the best way to go about doing this whilst maintaining the data structure?

The array is 20x50, containing bytes.

I'm sure I'd use a nested for loop, of course, but I can't work out how to utilise this to ensure that the array saved is identical to the one loaded, and vice versa.

Thanks in advance.

Google is your friend. I just entered: "Arduino saving data to EEPROM" and got over 28,000 hits. Surely one of those will set you in the right direction.

Yeah, I've researched it a lot. It's not the act of writing that's the issue, but maintaining the data structure.

Quite new to this so I'm not sure how to go about it.

Since you're just writing byte data to EEPROM, can you modify the program:

http://www.arduino.cc/en/Tutorial/EEPROMWrite

to suit your needs?

Two nested for loops would seem to be the easiest way to do this. Just make sure that you don't mix up the two dimensions when writing compared to reading, or maybe use a function to do it with a parameter indicating whether you want to read or write the array. That way they can't get mixed up.