I modify this code from my friend and it look strange.
void setup() {
Serial.begin(115200);
Serial.println("reset");
}
void loop() {
for (int d; d <= 32767; d++) {
Serial.println(d);
delay (1000);
}
}
for some reason when you press reset, the variable will keep counting from last value as shown.
this not gonna happen when you put these block in setup()
I know that not good idea to use varible in for loop without assigned the value, but I belived it must have a interesting reason for this. For my hypothesis, the variable value just allocate with same address in memory. when this code run in setup() some how the complier detect this situation and assign 0 as initial value. but when in the loop() some how the compiler don't assign new value to the memory address and it get old value from last time the program was run before resetted. I still need further explanation.