Filter by Tags
c-programming

What is the size of a pointer variable ?

Votes

1

1 0
Is the size of a character pointer different from the size of an int pointer or are their sizes same ? If they are same then what is the logic behind the size of all the pointers being the same ?
Ravinder Singh
Posted on : Fri, Jun 24, 2016
Views : 301
Comments

Ask Question

If you want to ask question you must LogIn or SignUp
Login SignUp

Answers (1)


0

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. 

The size of pointer is 2 bytes on 16 bit platform
The size of pointer is 4 bytes on 32 bit platform
The size of pointer is 8 bytes on 64 bit platform

Program

#include<stdio.h>

int main()
{
int *iptr = NULL;
float *fptr = NULL;
char *cptr = NULL;

printf("\nSize of Integer Pointer   : %d Bytes",sizeof(iptr));
printf("\nSize of Character Pointer : %d Bytes",sizeof(cptr));
printf("\nSize of Float Pointer     : %d Bytes",sizeof(fptr));

return 0;
}


Output :

Size of Integer Pointer : 4 Bytes
Size of Character Pointer : 4 Bytes
Size of Float Pointer : 4 Bytes
Manish Rawat
Sat, Dec 23, 2017
Loading...
Comments

Edit Answer

Submit
This answer will permanently deleted. Do you really want to delete this Answer ?
To Add your Answer Please
LogIn | SignUp

Quick Links

E-Magazines

@

Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..

Ok

Login to Open ESchool OR Create your account    Login   SignUp