I'm reading "Gray Hat Python". This book teaches debugging techniques in which you can change the variable value through the debugger.
In the code below the author teaches us how to change the counter
variable value. But I want to do more, so I add the 'Hello'
parameter to the printf
function so I can change it into something else like 'Bye'
.
What I found through the debugger is that 'Hello'
is stored on the Heap. The address in the Heap at which 'Hello'
is stored is saved in the Stack; why?
My question is: on what basis are some parameters stored on the stack and some on the heap?
from ctypes import *
import time
msvcrt = cdll.msvcrt
counter = 99999999
while 1:
msvcrt.printf("Loop iteration %d!\n" , counter, "Hello")
time.sleep(2)
counter += 1