
Pointer in C++
Understanding Pointer Size and Dereferencing in C/C++ Introduction Pointers are an important concept in C and C++. A pointer is a variable that stores the memory address of another variable . Instead of storing a value directly, it points to the location where the value is stored in memory. Understanding pointer size, dereferencing, and pointer assignment is essential for efficient memory management. Pointer Size in C/C++ The size of a pointer does not depend on the data type it points to . Instead, it depends on the system architecture (32-bit or 64-bit). For example, the following pointer types: int* char* float* double* long long* void* all have the same size on the same system. Pointer Size on Different Systems System Type Pointer Size 32-bit system 4 bytes 64-bit system 8 bytes Most modern computers use 64-bit architecture , so the pointer size is usually 8 bytes . Example Program #include <stdio.h> int main () { printf ( "%zu \n " , sizeof ( int * )); printf ( "%zu \n " , sizeof
Continue reading on Dev.to
Opens in a new tab



