"tom" <ee@w.ewrote in message news:ee**********@atlantis.news.tpi.pl...
He
How to get address in memory?
for example:
I would like 'ADR' be the adress in memory where 'srtBuf' starts
from debuger I know it is 0x003b1460 but how to get it by program?
char* srtBuf = new char[20];
long int ADR = 0x003b1460;
The srtBuf variable is a pointer. It holds the address of the start of the
buffer. If you want a long int variable to hold a pointer address, just
assign it, with a cast:
long int ADR = reinterpret_cast<long int>(srtBuf);
Note: This assumes that a pointer can fit in a long int on your system. On
some systems, addresses may be longer (or shorter) than a long int. (I'm
guessing that's why Marcin used intptr_t. But you used a long int, so I
showed how to use that.)
-Howard