I was asked these 2 questions during an interview. I guess the address of a static variable will be the same no matter where it is declared. It will also have the same address from run to run. Correct me if I am wrong.
If a static variable is declared out side of a function, will the memory address be the same as if it's declared in a function?
If a static variable is declared out side of a function, will it have the same address every time you run the program?
Cunningham's Law will ensure quick correction of my mistakes:
You need to disable address randomization to observe it:
If you add another global
static int j(commented out above) after the globalithen the effect goes away:So call me maybe!?