how much memory a pointer takes

Discussion in 'General Electronics Chat' started by aamirali, Jun 16, 2012.

  1. aamirali

    Thread Starter Member

    Feb 2, 2012
    415
    1
    1. how much memory a pointer takes, do it takes memory or it only points to address
    2. Also when i declare
    int *p
    how much memory it takes
     
    Last edited: Jun 16, 2012
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,392
    1,606
    Yes, it takes memory. Any variable you define takes memory.

    How much memory depends on what compiler and what device you're using.
     
  3. MrChips

    Moderator

    Oct 2, 2009
    12,446
    3,362
    A pointer is storage for a memory address hence the size of the storage will depend on the memory model of the target computer.

    For example, if the MCU has 64k memory space, it will require a 16-bit address.
    Hence the pointer will be a 16-bit memory location.
     
Loading...