Why can't I access code pointers?
Posted: Tue May 12, 2015 8:43 am
I simply want to acces the first byte of the code, but all I get is a reboot. I'm sure I made a stupid error, but I don't see it.
Code: Select all
int fubar(void) {
return random(100);
}
void setup() {
delay(5000);
Serial.begin(115200);
byte i = 7;
char *foo;
Serial.print("sizeof(foo): ");
Serial.println(sizeof(foo));
Serial.println("1111");
foo=(char *)&i;
Serial.print("Addr: ");
Serial.println((unsigned long )foo,HEX);
Serial.print("Value: ");
Serial.println((byte)*foo);
Serial.println("2222");
foo=(char *)&fubar;
Serial.print("Addr: ");
Serial.println((unsigned long )foo,HEX);
Serial.print("Value: ");
Serial.println((byte)*foo); // <-- reboots here
}
void loop() {
delay(1000);
}