Print what is at memory location

The following sketch prints this:

</sub> <sub>257 & 256 containing 1 12 respectively, i.e. 112, DEC 274, address of string "A". 259 & 258 containing 1 14 respectively, i.e. 114, DEC 276, address of string "BB". 261 & 260 containing 1 17 respectively, i.e. 117, DEC 279, address of string "CCC". 263 & 262 containing 1 1B respectively, i.e. 11B, DEC 283, address of string "DDDD". 265 & 264 containing 1 20 respectively, i.e. 120, DEC 288, address of string "EEEEE". 267 & 266 containing 1 26 respectively, i.e. 126, DEC 294, address of string "FFFFFF". 269 & 268 containing 1 2D respectively, i.e. 12D, DEC 301, address of string "GGGGGGG". 271 & 270 containing 1 35 respectively, i.e. 135, DEC 309, address of string "HHHHHHHH". 273 & 272 containing 1 3E respectively, i.e. 13E, DEC 318, address of string "IIIIIIIII".</sub> <sub>

// an array of pointers to char arrays
char* array1[] = {"GGGGGGG", "HHHHHHHH", "IIIIIIIII"};  // an array of pointers to char arrays
char* array2[] = {"DDDD", "EEEEE", "FFFFFF"};
char* array3[] = {"A", "BB", "CCC"};

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  printData(array3);
  printData(array2);
  printData(array1);

  while (1) {}
}

void printData(char ** myarray) //pointer to a pointer to a char array
{
  int address = 0;

  //  byte* pointer;
  //  pointer = (byte *)256;
  //  Serial.println(*pointer,HEX);


  address = (int) &myarray[0];
  Serial.print(address + 1);
  Serial.print(F(" & "));
  Serial.print(address);
  Serial.print(F(" containing "));
  Serial.print(((int)myarray[0] & 0xff00) >> 8, HEX);
  Serial.print(F(" "));
  if (((int)myarray[0] & 0xff) < 0x10)
  {
    Serial.print(F("0"));
  }
  Serial.print((int)myarray[0] & 0xff, HEX);
  Serial.print(F(" respectively, i.e. "));
  Serial.print((int)myarray[0], HEX);
  Serial.print(F(", DEC "));
  Serial.print((int)myarray[0], DEC);
  Serial.print(F(", address of string \""));
  Serial.print(myarray[0]);
  Serial.println(F("\". "));

  address = (int) &myarray[1];
  Serial.print(address + 1);
  Serial.print(F(" & "));
  Serial.print(address);
  Serial.print(F(" containing "));
  Serial.print(((int)myarray[1] & 0xff00) >> 8, HEX);
  Serial.print(F(" "));
  if (((int)myarray[1] & 0xff) < 0x10)
  {
    Serial.print(F("0"));
  }
  Serial.print((int)myarray[1] & 0xff, HEX);
  Serial.print(F(" respectively, i.e. "));
  Serial.print((int)myarray[1], HEX);
  Serial.print(F(", DEC "));
  Serial.print((int)myarray[1], DEC);
  Serial.print(F(", address of string \""));
  Serial.print(myarray[1]);
  Serial.println(F("\". "));

  address = (int) &myarray[2];
  Serial.print(address + 1);
  Serial.print(F(" & "));
  Serial.print(address);
  Serial.print(F(" containing "));
  Serial.print(((int)myarray[2] & 0xff00) >> 8, HEX);
  Serial.print(F(" "));
  if (((int)myarray[2] & 0xff) < 0x10)
  {
    Serial.print(F("0"));
  }
  Serial.print((int)myarray[2] & 0xff, HEX);
  Serial.print(F(" respectively, i.e. "));
  Serial.print((int)myarray[2], HEX);
  Serial.print(F(", DEC "));
  Serial.print((int)myarray[2], DEC);
  Serial.print(F(", address of string \""));
  Serial.print(myarray[2]);
  Serial.println(F("\". "));

  //  Serial.print(F("\" 1st character in the string is = \""));
  //  Serial.println(*myarray[0]);       //print the first chr in the string


}

How can I print what the byte contents are at SRAM memory location is 257?

Something like:
int *pointer;
pointer = 257;
Serial.println(*pointer) //which obliviously does not work.

.
.

Why not?

You would probably need a cast:

pointer = (int *)257;

http://c-faq.com/osdep/rawmemadr.html

If that doesn't work:
http://c-faq.com/null/accessloc0.html

Yeah, of course. But because he does the inverse (cast to int) when printing the address I thought that to be trivial. But that might just be me :smiley:

KeithRB:
You would probably need a cast:

pointer = (int *)257;

Question 19.25

If that doesn’t work:
Question 5.19

That was the answer.
Thank You

This works:
byte* pointer;
pointer = (byte *)256;
Serial.println(*pointer,HEX);