![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
|||
|
|||
How do you find the return address in an array of integers?How do you find the return address in an array of integers?
|
|
#2
|
|||
|
|||
Re: How do you find the return address in an array of integers?Please give a full explanation of your problem. Start with the Guidelines you missed reading.
__________________
Please read http://www.gidforums.com/t-5566.html. They were written to help you create a request that is readable and has enough information we can actually tell what you need help with. |
|
#3
|
|||
|
|||
Re: How do you find the return address in an array of integers?Quote:
What do you mean by "return address"? Do you mean the address of the array? The address of an array of anything is the address of the first element. The programmer doesn't need to know the actual value of the address for normal programs, but sometimes it's helpful in debugging. Anyhow, if you use the name of the array without the [brackets], the compiler treats it as if you had used the address operator on the first element of the array. That is, it is treated as a const pointer to int in this case. You can print out the hexadecimal value of the address with printf("%p"), as you can see from the following: CPP / C++ / C Code:
Here is a run. Note that the actual addresses shown may be quite different, depending on your compiler and other things, but they will agree for any given compiler for this program on your system. Code:
So, knowing the address of the array is not really useful (except for debugging). By the way, you do know that the addresses printed out by this program aren't actually physical addresses of real memory, right? (Except possibly for some embedded systems that don't have or don't use memory mapping for their processors.) For our PCs running Windows XP or Linux, the addresses are "virtual addresses" that our program owns while it is running, and they are mapped to actual physical addresses by the operating system each time the program is loaded. That is, you might see the same numbers in the printout of this program each time, but they don't necessarily resolve to the same physical address each time. Regards, Dave |
Recent GIDBlog
Developing GUIs with wxPython (Part 2) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Pointer Usage in C++: Beginner to Advanced | varunhome | C++ Forum | 0 | 19-Aug-2005 09:25 |
| Problem with one variable | bretter | C++ Forum | 1 | 16-May-2005 07:20 |
| template comiling problems - need expert debugger! | crq | C++ Forum | 1 | 01-Feb-2005 21:26 |
| C++ file I/O | CronoX | C++ Forum | 36 | 09-Mar-2004 17:28 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The