size of a pointer

This is a discussion on size of a pointer within the C++ Programming forums, part of the General Programming Boards category; purely out of curiosity, does anyone know the size of a pointer in memory (under Windows OS)?...

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    22

    size of a pointer

    purely out of curiosity, does anyone know the size of a pointer in memory (under Windows OS)?

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    sizeof(void*)
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    Apr 2005
    Posts
    22
    thanks, should have thought of that myself

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,590
    http://www.eskimo.com/~scs/C-faq/q5.17.html
    You should regard each pointer as a different type, which may have a different representation than other pointer types (and consequently, a different size).

    I suppose the implication of this (given the rules for C) that a void* pointer is big enough to hold any pointer type (since assignment to void* and back again preserves information).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Size of an object/variable from its pointer?
    By cerberus_jh in forum C Programming
    Replies: 14
    Last Post: 12-10-2008, 11:51 AM
  2. Invalid conversion from 'void*' to 'BYTE' help
    By bikr692002 in forum C++ Programming
    Replies: 9
    Last Post: 02-22-2006, 10:27 AM
  3. towers of hanoi problem
    By aik_21 in forum C Programming
    Replies: 1
    Last Post: 10-02-2004, 01:34 PM
  4. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM
  5. size of the memory reserved for a pointer
    By cris_orpi in forum C Programming
    Replies: 13
    Last Post: 03-05-2003, 10:42 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21