Discussion :: Complicated Declarations - Find Output of Program (Q.No.4)
|Deepak said: (Aug 15, 2010)|
|Please explain this to me.|
|Mehul said: (Oct 27, 2010)|
|I don't understand. Please must be explain.|
|Suresh@Pdtr said: (Jan 19, 2011)|
It's easy to remember,
as we can say when ever after (huge,far,near) declaration of a pointer variable it takes default sizes of huge, near, far.!
|N N said: (Mar 3, 2011)|
|The code has syntax errors.|
|Kumar said: (Mar 3, 2011)|
The above code works fine in Turbo C as said.
But in GCC it not works.
Is this due to platform dependency of C compiler?
Can you explain please?
|Sai said: (Jun 3, 2011)|
|it will consider the *far *ptr1---------------- * far 4bytes
*huge *ptr2--------------- *huge 4 bytes
*near *ptr3 -----------------near 2 bytess
|Sarfraj said: (Oct 3, 2011)|
|I m not able to understand that, please give more explanation.|
|Seshan said: (Oct 16, 2011)|
|I can't understand can you explain me with full reference.|
|Somnath said: (Nov 28, 2011)|
|ptr1 is a pointer to a far pointer for that the size is 4
ptr2 is a pointer to a huge pointer for that the size is 4
ptr3 is a pointer to a near pointer for that the size is 2
|Sandeepasri said: (Dec 15, 2011)|
|Deepika said: (Feb 23, 2012)|
|All the varibles have same type ouput is 4,4,4 but output is 4,4,2|
|Gautam A Naik said: (Apr 6, 2012)|
|But why is sizeof (ptr3) will give output as 2?. please explain me.|
|Ravi said: (May 31, 2012)|
|Think it like this :
ptr1 is a far pointer to a near pointer to a huge pointer to char .
Think arrow (->) sign as "pointing to" :
ptr1 (far type) -> *ptr1 (near type) -> **ptr1(huge type) -> ***ptr1 (char type)
sizeof(ptr1)= far pointer size = 4 bytes
sizeof(*ptr1)= near pointer size = 2 bytes
sizeof(**ptr1)= huge pointer size = 4 bytes
|Adarsh said: (Jul 21, 2012)|
|Actually far and near are related to fact that how we are accessing the variable i.e. absolute or relative.
Relative = "near";.
When we are accessing variable relative, then we hav to store only relative address that account for our 2 bytes of memory.
And the rest is understood.
|Kavi said: (Sep 23, 2012)|
|What is the purpose of near, huge and far pointers. Explain with an example program?|
|Hany said: (Sep 28, 2012)|
|Why we consider the size of far, huge and near as 4, 4 and 2 respectively. Then in declaration of first line also there is near so why it takes 4bytes of size?|
|Rampa said: (Nov 15, 2012)|
|There is something known as memory segment for near it saves relative memory and far and huge it saves absolute memory.
For a 32 bit machine memory bus width is 32 bit that means it can support maximum of 2^32 capacity that is 4Gb memory. In the sense to store address of any byte in absolute form we need 32 bit pointer (full address). But in near there will be something base pointer (internally) which stores 32 bit address and all other pointer which we declare stores only relative address that is 2 bytes. For example if base has 10000000h address and p=ffffh (where p is pointer) then absolute address of p is 10000000h+ffffh=1000ffffh. Where base address contains the starting address of a near segment.
|Rohit said: (Sep 12, 2013)|
char huge *near *far *ptr1;
printf("%d %d\n", sizeof(***ptr1),sizeof(****ptr1));
|Priyanka said: (Jul 11, 2014)|
|Irrespective of pointer it declares far is of size 4,
Huge is of size 4,
Near is of size 2.
|Divya said: (Jun 17, 2016)|
|Don't understand the concept of near far huge pointers. Help me by explaining this.|
|Arusha said: (Jul 15, 2016)|
|Can't understand it. Explain.|
|Ashwini said: (Jul 24, 2016)|
|Can't understand it. Explain it more detail.|
|Krishnaveni said: (Sep 11, 2016)|
|I can't understand. It's so confusing. Please explain me clearly.|
|Aparna said: (Jan 13, 2017)|
|Unable to understand please someone explain in steps.|
|Ajay Paratmandali said: (Mar 1, 2017)|
|Huge = 4.
Far = 4.
Near = 2.
Ptr1-far *ptr1-near **ptr1-huge.
Ptr2-huge *ptr2-far **ptr2-near.
Ptr3-near *ptr3-huge **ptr3-far.
|Sahithi said: (Jun 7, 2017)|
|When working on architectures with segmented memory (like x86 real mode), one can distinguish three types of pointer addresses (examples for x86 in segment:offset notation):
Only stores the offset part (which is 16-bit) - when resolving such a pointer, the current data segment offset will be used as segment address.
Stores segment and offset address (16 bit each), thus defining an absolute physical address in memory.
Same as far pointer, but can be normalized, i.e. 0000:FFFF + 1 will be wrapped around appropriately to the next segment address.
|Nawaz said: (Feb 15, 2018)|
|I am not getting how it is taking size? So please anyone explain this in detail.|
|Gitpr said: (Mar 4, 2018)|
|Why can't I find huge near or far on cppref? Please explain.|
|Manohr said: (May 2, 2019)|
|Can anyone explain in detail to me?|
|Divya said: (Jul 25, 2019)|
|Chat huge *near *far *ptr1;
Ptr1= far so 4// check from right to left.
char near *far *huge *ptr2;
*Ptr2= far so 4// one star so second is taken.
char far *huge *near *ptr3;
**Ptr3=far so 4.
|Nivedita.S.J said: (Jan 24, 2020)|
|Shubham Mittal said: (Sep 12, 2020)|
|Far pointer size 32 bytes = 4 bit.
Huge pointer size 32 bytes = 4 bit.
Near pointer size 32 bytes = 2 bit.
So, the answer is= 4, 4, 2.
Post your comments here:
Email : (optional)
» Your comments will be displayed only after manual approval.