View Single Post
  #4   Spotlight this post!  
Unread 03-16-2011, 09:09 PM
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: I Have A Question About Pointers

If it is a variable, it takes up space in memory. A char variable takes 1 byte, a short variable takes 2 bytes, a long variable takes 4 bytes, an int on a 32-bit machine takes 4 bytes. A pointer variable on a 32-bit machine also takes 4 bytes.
Code:
int A = 40;
long B = 50;
int *ptrToA = &A;
long *ptrToB = &B;
 
addr           value      variable name
====           =====      =============
        +----------------+
1000    |       40       |  A
        +----------------+
1004    |       50       |  B
        +----------------+
1008    |      1000      |  ptrToA
        +----------------+
1012    |      1004      |  ptrToB
        +----------------+
        |      ....      |
__________________

Last edited by mikets : 03-16-2011 at 09:12 PM.
Reply With Quote