byte to char array

Hello,

I want to read a phone number with eeprom, then send a text message with GSM to that phone number.

My code for retrieving the stored number.

void getRemoteNumber()
{
    int address = 0;
    bool atEmptyByte = false;

    while (!atEmptyByte) {
        byte value = EEPROM.read(address);
        // Need to append 'value ' to a char array here.
        if (value == 0) {
            atEmptyByte = true;
        }
    }
}

As you can see, EEPROM.read returns a byte.
How can I create a char array for use in GSM_SMS.print(); ?

Thanks

totally off the top of my head. Haven't even tried compiling it.

void getRemoteNumber()
{
    int address = 0;
    bool atEmptyByte = false;
   
   //you want somewhere to store it.
    char number[50];
    int index=0;

    while (!atEmptyByte) {
     //store it in the array and update the index at the same time  
     number[index++] =(char)  EEPROM.read(address);
        // Need to append 'value ' to a char array here.
        if (value == 0) {
       //terminate the string  n
             number[index]=0;
            atEmptyByte = true;
        }
    }
}
[code]

[/code]

I want to read a phone number with eeprom, then send a text message with GSM to that phone number.

How are the numbers stored ? Please post the code that stores the number.

Your use of 0 as a test that the full number has been read seems to indicate that 0 will not occur in the number, so are the numbers be converted to ASCII before being saved ?

However the number is stored, your code is flawed because it reads each digit from address 0.

Hello,

Thank you for your reply’s

This is my code to store the phone number

void clearEEPROMData()
{
  for (int i = 0; i < 512; i++) {
    EEPROM.write(i, 0);
  }
}

void setRemoteNumber(char remoteNumber[])
{
  clearEEPROMData();
  int remoteNumberLength = strlen(remoteNumber);
  for (int i = 0; i < remoteNumberLength; i++) {
    EEPROM.write(i, remoteNumber[i]);
  }
}

Thanks