Home > Back-end > C language tutorial of some questions about the virtual address, consult?
C language tutorial of some questions about the virtual address, consult?
Time:10-04
The original In C, the value of the pointer variable is a memory address, & amp; The role of the operator is also variable memory address, please see the following code
# include & lt; stdio.h> # include & lt; Stdlib. H> Int a=1, b=255; Int main () { Int * pa=& amp; a; Printf (" pa=% # X, & amp; B=% # X \ n ", pa, & amp; B); system("pause"); return 0; }
In C - Free run under 5.0, the result is: Pa=0 x402000, & amp; B=0 x402004
Code of a, b is a global variable, their memory address at link time has decided, later any further can't change, whenever the program running, the result is the same,
Above is the original code, and then I saw the other articles on the net, they run every time the output results are the same, But every time I run to get the address is change, how be to return a responsibility? The following is my run results, every time is not the same: Pa=0 x1278034, & amp; B=0 x1278038 Pa=0 x368034, & amp; B=0 x368038 Pa=0 xfe8034, & amp; B=0 xfe8038
CodePudding user response:
Each run, the allocation of memory location is not the same as bai, that's normal ~ your computer has been running the program, may be the last time to use the location of the for use by other applications, it is possible,