Thread: Pointer type?

  1. #1

    Question Pointer type?

    Whenever you declare a pointer type does the compiler set aside only enough memory for that type? Or does it still use 4 bytes?

    Or is that the whole point behind needing to declare a pointer type; to set aside enough memory?

  2. #2
    Registered User Cela's Avatar
    Join Date
    Jan 2003
    >>Or does it still use 4 bytes?
    It doesn't have to be 4 bytes, the compiler sets aside enough memory for a single pointer of type T, or

    sizeof(T *)

  3. #3
    Registered User
    Join Date
    Apr 2002
    A pointer is always going to point to a memory location. The memory location size is fixed for a given machine ( 4 bytes on 32-bit machines ). But if you just had void *'s everywhere and you wanted to do pointer arithmetic how would the compiler know how much to increment the memory address? So if you have an int * and you increment the pointer by 1 it will jump ahead 4 bytes ( the size of 1 int ). Hope this helps you a little bit.

  4. #4
    I think I had a brain fart. I had forgot that all a pointer does is point to a memory address. LOL. Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. strings Vs. Char pointers
    By aijazbaig1 in forum C Programming
    Replies: 49
    Last Post: 02-13-2008, 09:51 AM
  2. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  3. Compiler "Warnings"
    By Jeremy G in forum A Brief History of
    Replies: 24
    Last Post: 04-24-2005, 01:09 PM
  4. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  5. Another Linked List plee
    By Dragoncaster131 in forum C Programming
    Replies: 3
    Last Post: 05-15-2004, 05:40 PM