2 bytes of memory because the pointer variable, whatever data type it maybe pointing to is always an unsigned integer as the address is always a positive integer, hence requiring 2 bytes of memory
2 bytes of memory because the pointer variable, whatever data type it maybe pointing to is always an unsigned integer as the address is always a positive integer, hence requiring 2 bytes of memory
& address is of the type integer, it can't be a character or a float.
& Integer takes two bytes to store So answer would be 2bytes.
maggi
Sep 3rd, 2011
2 bytes
suman
Sep 3rd, 2011
*p means there is no certain amount of memory allocated for that it will take what data you give and there is no limitation like up to this size. There is no waste of memory.
navatha
Sep 7th, 2011
2
shafi
Sep 7th, 2011
depends on the data types....but this answer is 1 byte....
shiva
Sep 10th, 2011
1 byte
ronak
Sep 10th, 2011
2 bytes of memory will be allocated, as pointer always point to the unsigned integer as address are unsigned integer.
SHILPA
Sep 23rd, 2011
it will take 2 bytes. because pointer always take 2 bytes
I know Ive answered this already, but I thought Id include a handy macro definition for getting the size of any type (pointer or otherwise) on your platform (see code insert). FWIW, here are the results on my system (Linux 2.4.20, gcc compiler in C99 mode):
Size of char = 1
Size of char * = 4
Size of unsigned char = 1
Size of unsigned char * = 4
Size of short = 2
Size of short * = 4
Size of unsigned short = 2
Size of unsigned short * = 4
Size of long = 4
Size of long * = 4
Size of unsigned long = 4
Size of unsigned long * = 4
Size of long long = 8
Size of long long * = 4
Size of unsigned long long = 8
Size of unsigned long long * = 4
Size of float = 4
Size of float * = 4
Size of double = 8
Size of double * = 4
Size of long double = 12
Size of long double * = 4
Size of struct {char a; char b; long y;} = 8
Size of struct {long y; char a; char b;} = 8
Size of struct {char a; char b; long y;} * = 4
Size of union {char a; char b; long y;} = 4
Size of union {char a; char b; long y;} * = 4
Code
#include <stdio.h>
#if defined(__STDC__)
#if defined(__STDC_VERSION__)
#if __STDC_VERSION__ >= 199901L
#define C99 1
#endif
#endif
#endif
#ifdef C99
#define fmt "%zu"
#define cast
#else
#define fmt "%lu"
#define cast (unsigned long)
#endif
#define PRINT_SIZE(t) printf("Size of %-30s = " fmt "
It depends on how much bit Turbo C software you are using. If it is 32 bit then it will take 4 byte. If it is 64 bit then pointer will take 8 bytes of memory.
Alejandro
Mar 5th, 2016
It Depends on the architecture which is building on.
- In a 16-bit addressing system, 2 bytes.
- In a 32-bits addressing system 4 bytes.
- In a 64-bits addressing system 8 bytes.
Even in old architectures of 16-bits (80x286), depending if it was a far pointer it would size 32-bits (segment + offset).
Raees Ul Islam
Nov 25th, 2021
Pointer is actually is a reference to memory cell. In 32bit operating system, OS use 4 byte for pointing to any memory cell thats why only 4GB memory can be used in 32bit operating system. On the other hand a 64bit OS use 8byte for addressing.
So size of pointer depends upon OS, In 32bit OS pointer will take 4byte and in 64bit OS pointer will take 8 bytes.
No matter pointer is for char, int, bool, Structure it will remain same for all types
If we declare a pointer like char *p;how much memory is allocated for pointer variable 'p'.
Profile Answers by pavankishore Questions by pavankishore
Questions by pavankishore answers by pavankishore
Editorial / Best Answer
winny guptaProfile Answers by winny gupta Questions by winny gupta
2 bytes of memory because the pointer variable, whatever data type it maybe pointing to is always an unsigned integer as the address is always a positive integer, hence requiring 2 bytes of memory