Monday 18 March 2013

char far *farther,*farthest;


void main()
{
 char far *farther,*farthest;
 
 printf("%d..%d",sizeof(farther),sizeof(farthest));
  
 }
Answer:
4..2 
Explanation:
    the second pointer is of char type and not a far pointer.
Some explanation first:
far pointers are outdated concepts from C, and are actually
compiler extentions, so you might get compiler errors trying
to use far pointers on some compilers.
In the program above, 
farther's type - FAR pointer to char
farthest's type - near pointer to char
now, the difference in size of those stems from the fact
that far pointers consist of the segment and offset
together, while near pointers just have the offset. 
Near pointers thus have size of 2 (just the offset), while
far pointers - size of 4 bytes.

Blog Author: Vijay Kumar
Go to: Java Aptitude

No comments:

Post a Comment