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.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Create a free website or blog at

Up ↑

Create your website with
Get started
%d bloggers like this: