Hire a web Developer and Designer to upgrade and boost your online presence with cutting edge Technologies

Wednesday, January 19, 2011

In C/C++ languageBetween a long pointer and a char pointer , which one consumes more memory? explain

Between a long pointer and a char pointer , which one consumes more memory? explain



1)NO doubt in this...
always pointer variable is going to store a memory location.... its not a matter its long or char or int or any thing...
so this two is taking same amount of memory.

2)Long pointer consumes more memory as it can go beyond the memory limit of 1K. So more address more space.

3)NO doubt in this...
always pointer variable is going to store a memory location.... its not a matter its long or char or int or any thing...
so this two is taking same amount of memory.

4)
Both will consume same amount of memory.why because they means long or char pointer always stores the address of the character or long integer .

5)Whatever may be the pointer (whether it points to char int or float) the memory allocated is same i.e 2 bytes

6)1) As We All Know That Pointer(*) Holds Address!
2) Address is Always INTEGER (2-Bytes)
3) Hence 2-Bytes Are Allocated For Any Data Types!

7)
pragmatic approach is the best approach. Just to support above comment.printf( d sizeof(long *));printf( d sizeof(char *));printf( d sizeof(double *));


8)I think pointers take 4 bytes in a 4GB virtual memory space which is true for most of the OS in nowadays.


9)Both the long pointer and char pointer consumes the same memory.
By declaring variable as a long pointer means that it contains the address of another long variable and also for char pointers it contains the address of another char variable.
So all normal pointers have only two bytes for storing the address.


10)If the question is regarding the data type long and the data type char then both long pointer and char pointer occupy the same space ie 2 bytes

But I think in C there is a special kind of pointers called long pointers. These pointers are more than 2 bytes in size. Hence they can hold the address of the variables which are quite far away. Hence the name long pointer



11)I am sorry the 2 part of the above answer is wrong.....

I confused long pointer with far pointer

SIze of long pointer and char pointer will be the same

 
   
 
 

No comments:

Post a Comment