what is the base data type of a pointer variable by which the memory would be allocated to it?
In C and C++, a pointer variable itself doesn't have a "base data type" in
the sense of int or float for the memory allocated to store the pointer. The
pointer is a distinct type (e.g., int* or char*) that holds a memory
address, and its size is fixed regardless of what it points to—typically 4 or
8 bytes on modern systems.
Core Concept
Pointers store addresses, not values of a specific base type. The memory for
the pointer variable (e.g., via stack or malloc) is allocated based on the
platform's pointer size, like sizeof(int*). This is independent of the
pointed-to type, debunking MCQ claims like "unsigned int" from exam sites.
For example:
int *ptr;allocates space for an address (say 8 bytes on 64-bit).- No "base type" like int dictates this; it's architecture-driven.
Multiple Viewpoints
- Exam/Quiz Angle : Sites like Examveda say "unsigned int," but that's misleading—pointers aren't unsigned ints; they may share size.
- Stack Overflow Consensus : Size is uniform; e.g.,
int*anddouble*both takesizeof(void*)bytes. No dependency on pointee.
- GeeksforGeeks View : Pointer type is derived, but storage is address-sized, not base-typed.
Aspect| Pointer Storage| Pointee Influence
---|---|---
Size| Fixed (e.g., 8 bytes on x64) 3| None on pointer itself
Declaration| int* p 5| Affects dereference (*p)
Allocation| Stack/heap for pointer var 3| Separate for pointed data
Real-World Example
c
int x = 10;
int *p = &x; // p gets ~8 bytes for address
printf("%zu\n", sizeof(p)); // Prints pointer size, not int
This highlights: Pointer memory is for the address holder, not a "base" like int.
TL;DR: No universal base data type; pointers allocate platform-specific address storage (e.g., 8 bytes), independent of what they point to.
Information from public forums and web sources as of Feb 2026.