eeprom write

Hi!

i want to write a number like 123456 on EEPROM. the maximum writable value is 255 so I want to write 1 - 2 - 3 - 4 - 5 - 6 on EEPROM. My question is: how can I "cut a number into pieces"? Is this possible? does my idea make sense?

Martin

http://arduino.cc/playground/Code/EEPROMWriteAnything

IT CAN BE AS FOLLOWS:

open a notepad and put this code in it and save it as EEPROMAnything.h(with .h extension)

#include <EEPROM.h>
#include <Arduino.h>  // for type definitions

template <class T> int EEPROM_writeAnything(int ee, const T& value)
{
    const byte* p = (const byte*)(const void*)&value;
    unsigned int i;
    for (i = 0; i < sizeof(value); i++)
          EEPROM.write(ee++, *p++);
    return i;
}

template <class T> int EEPROM_readAnything(int ee, T& value)
{
    byte* p = (byte*)(void*)&value;
    unsigned int i;
    for (i = 0; i < sizeof(value); i++)
          *p++ = EEPROM.read(ee++);
    return i;
}

Then you just have to use this code

#include <EEPROM.h>
#include "EEPROMAnything.h"

struct config_t
{
    long alarm;
    int mode;
} configuration;

void setup()
{
    EEPROM_readAnything(0, configuration);
    // ...
}
void loop()
{
    // let the user adjust their alarm settings
    // let the user adjust their mode settings
    // ...

    // if they push the "Save" button, save their configuration
    if (digitalRead(13) == HIGH)
        EEPROM_writeAnything(0, configuration);
}

we can do this EEPROM_readAnything(0,T& value);
EEPROM_writeAnything(0, T& value);

Isn't that what the link James posted says?