Re: Memory address and Pointer



erfan wrote:
vc++6.0,winxp.
I use this code to see the memory address and the real value`s
address below:
#include<stdio.h>
int main()
{
int a=22;
int *p;
int i;
p=&a;
printf("%x\n",&a);
printf("%p\n",*p);
}
the result is:
12ff7c

So ,next,i use win Debug to help me.
-d 0012:ff7c
but the output is 00 00 00 00 00 00 00 00 00......

ignoring the errors in printf which others have commented on, the above isn't likely to work anyway. In most modern OSes, programmes have their own memory space and another application normally can't invade that. Also the 'debug' app you're using seems to be a 16-bit app, and the address format you're supplying looks very much like a 16-bit format. Neither of these will be valid ways of accessing data in a 32-bit programme in different memory space!

.



Relevant Pages