473,396 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

address in memory

tom
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;

t.
Sep 21 '06 #1
3 1678
tom napisał(a):
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;

t.

intptr_t ADR = reinterpret_cast<intptr_t>(srtBuf);

--
Marcin Gabryszewski
G DATA Software
www.gdata.pl

address:<FirstName><dot><Surname><at><gdata><dot>< pl>
Sep 21 '06 #2
tom wrote:
for example:
I would like 'ADR' be the adress in memory where 'srtBuf' starts
char* srtBuf = new char[20];
long int ADR = 0x003b1460;
Simple:

void* ADR = srtBuf;

A void* is what you use to denote an address in memory when you don't
care about the type. You can print it using std::cout << ADR <<
std::endl;

HTH,
Michiel Salters

Sep 21 '06 #3

"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
Sep 21 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Gidraz | last post by:
Hello, i can't figure out how to retrieve clients MAC address using C#.NET. I can get IP but not MAC. Thanks in advance. Gidraz
22
by: ypjofficial | last post by:
Hello All, While readling the C and C++ literature i came to know that the OS allocates separate protected memory space for each running program and the program do not interfare into one another's...
5
by: Jeong-Gun Lee | last post by:
I'm writing a code of writing a value to a specific memory address. ================================================================= #include <stdio.h> int main() { long air; long...
3
by: Nadav | last post by:
Hi I wonder... Is it possible to define the address to which shared memory will be mapped In other words is it possible to apriory define the address MapViewOfFile returns Dlls are being loaded...
15
by: mangesh | last post by:
This code is from c++ faq in section 11 : void someCode() { char memory; void* p = memory; Fred* f = new(p) Fred(); f->~Fred(); // Explicitly call the destructor for the placed object }
5
by: kumarsssss | last post by:
I have just new to degugger. It shows the data registers and address registers. Data registers contatin the data values for the different variables. But what the address registers holds? Does...
57
by: Robert Seacord | last post by:
i am trying to print the address of a function without getting a compiler warning (i am compiling with gcc with alot of flags). if i try this: printf("%p", f); i get: warning: format %p...
3
by: Newish | last post by:
Hi Regarding DLL base address: 1) What does it mean? 2) Should it ever be changed? 3) What are the rules to change it?
20
by: sethukr | last post by:
hi, i need to store a value to a particular memory location without having a variable. So, how can i access a 'memory address' without using variables?? Is it possible in C??? Plz, help...
5
by: erfan | last post by:
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;
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.