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

Showing Answers 1 - 19 of 19 Answers

Mridul

  • Jun 23rd, 2006
 

Long pointer consumes more memory as it can go beond the memory limit of 1K. So more address, more space.

  Was this answer useful?  Yes

kannan

  • Jun 24th, 2006
 

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.

krishna reddy

  • Jul 4th, 2006
 

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 .

Thanks for reading my opinion.

aruneshwar

  • Jul 7th, 2006
 

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

shaanxxx

  • Aug 20th, 2006
 

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

  Was this answer useful?  Yes

jintojos

  • Jul 7th, 2008
 

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. 

  Was this answer useful?  Yes

abhimanipal

  • Jul 20th, 2009
 

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

  Was this answer useful?  Yes

abhimanipal

  • Jul 20th, 2009
 

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

  Was this answer useful?  Yes

kbjarnason

  • Jul 1st, 2010
 

As a general rule of thumb, object pointers (as opposed to function pointers) will typically be the same size, as the relevant information - memory address - requires the same size regardless of type.

That said, there are, as far as I know, no guarantees that they cannot in fact differ in size; there are certainly no guarantees that they are type compatible.  Which is to say if you have a pointer-to-int and attempt to assign it to a pointer-to-double, even if the sizes are the same, the layout may not be and the results may be a mess.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions