What is size of a pointer variable

What is size of a pointer variable.

Size of a pointer variable is system dependent. A memory address is considered as integer value. Size of a pointer is fixed, it doesn’t depend on the data type it is pointing to. We can use size of operator to get the size of a pointer.

What is size of void pointer in C.

The size of any type of pointer in C is equal to the size of the integer variable in that system. For example, in a 16 bit system size of integer is 2 bytes which is same as size of pointer.

A pointer stores the memory address of a variable and address of a variable is nothing but the integer value. So, a pointer variable stores an integer value that means size of a pointer variable is same as size of integer variable. The size of pointer variable is independent of the data type of the variable it is pointing to because at the end it is pointing to a memory location. Hence the size of char pointer, int pointer, float pointer, NULL pointer etc are all same.

What is difference between uninitialized(wild) pointer and null pointer.

A Pointer in C that has not been initialized till its first use is known as uninitialized pointer. Uninitialized pointer points to some random memory location. NULL pointer in C is a pointer which is pointing to nothing or the base address of the segment.

For Example:

int *ptr1 = NULL;
int *ptr2;

Here ptr1 is a NULL pointer whereas ptr2 is an uninitialized(wild) pointer.

What is pointer to a function in C

const pointer always points to same memory location. Once a const pointer is initialized to point to a memory location we cannot change it to point to some other memory location. However we can change the data stored at that memory location.

Leave a Comment