Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Size of a Pointer based on datatype

There is a lot of confusion about the size of the Pointers based on datatypes. A usual question is if there is a difference of size in:

int *p;
char *p;
string *p;

The answer is simple. As we discussed in the previous detailed post on pointers, A Pointer Points to the address of a memory location. So, the data type declared is actually of the content stored at that address. Therefore, datatype has nothing to do with the size of pointers.

So, we can easily understand that the size of pointer is 32-bit or 64-bit based on the machine as the pointer points to a certain address of memory. Same goes for void pointers.



This post first appeared on BUG FIXES AND CODING SOLUTIONS, please read the originial post: here

Share the post

Size of a Pointer based on datatype

×

Subscribe to Bug Fixes And Coding Solutions

Get updates delivered right to your inbox!

Thank you for your subscription

×