![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jun 2006
Posts: 2
Rep Power: 0
![]() |
Pointer Storage
Hi, How does a pointer gets store in memory ?
|
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Same was as anything else; it gets assigned a memory location. This is most often referenced by a label, such as "myPtr." The pointer standing alone is useless and dangerous. Check the link in my signature for material on pointers.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: May 2006
Location: West Jordan, Utah, United States
Posts: 176
Rep Power: 3
![]() |
In 32-bit mode, the processor treats integer and pointer data-types the same*. You can cast a pointer to an integer and vice versa, although this is unwise!
*In 64-bit systems and "64-bit compliant" systems, a 64-bit pointer is used. On all systems, a pointer is represented by a numerical value. This is pretty intuitive. Right? |
|
|
|
|
|
#4 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
I'm sorry, Harakim, but your post is misleading and somewhat inaccurate and is, further, introducing some implementation-dependent information. Please be as careful as possible when imparting information to novices.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Jun 2006
Posts: 2
Rep Power: 0
![]() |
Pointer
So, how big would the memory space be for the pointer same as an normal var per say an int?
Another question this one is a very silly one but I can't seem to find an answer to it. On page 93 of "The C programming Language 2nd edition" well I can't undestand what they mean by the graphic at the bottom. Thanks for the response. |
|
|
|
|
|
#6 | |
|
Caffeinated Neural Net
![]() Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,107
Rep Power: 5
![]() |
Quote:
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
|
|
|
|
|
|
#7 | ||
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,253
Rep Power: 5
![]() |
Quote:
Quote:
All that aside, there is really little point in debating whether an int and a pointer are the same size, or which is the "common" usage. They are the same size on some target machines, and are different sizes on some other machines --- and both types of machines are quite common. So writing code that assumes they are the same size is asking for trouble: either you get "lucky" and run into trouble because your machine has int and pointers of different sizes. Or your get unlucky, and get a program that appears to run well, until you decide to port it to another machine or (even) to another compiler on the same machine. |
||
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|