The Ultimate Guide to Understanding the Size of a Pointer

When we declare a pointer, the size of the pointer will be determined by the memory model used while installing the Turbo C/ C++ compiler software.

Program to know the default size of a pointer

#include<stdio.h>
void main()
{
  int *ptr1;
  int *ptr2;
  printf("\n Size of int pointer: %d", sizeof(ptr1));
  printf("\n Size of char pointer: %d", sizeof(ptr2));
}

Output:

Size of int pointer: 2
Size of char pointer: 2
Naveed Tawargeri
 

Hi, I'm Naveed Tawargeri, and I'm the owner and creator of this blog. I'm a Software Developer with a passion for Programming.