C Programming - Complicated Declarations - Discussion
Discussion Forum : Complicated Declarations - Find Output of Program (Q.No. 3)
3.
What will be the output of the program?
#include<stdio.h>
int main()
{
char huge *near *far *ptr1;
char near *far *huge *ptr2;
char far *huge *near *ptr3;
printf("%d, %d, %d\n", sizeof(**ptr1), sizeof(ptr2), sizeof(*ptr3));
return 0;
}
Discussion:
31 comments Page 1 of 4.
Arun said:
2 decades ago
Confused about these near, far, huge pointers.
Can anyonre explain this concept?.
Can anyonre explain this concept?.
Khattu said:
1 decade ago
near, far, huge these are deprecated.
Vijay said:
1 decade ago
Near pointer : If the size of the program is very large the program may create a near pointer to a piece of frequently accessed memory so as to enhance performance.
But I am curious to know that so the near pointer is allocated/ created by the system rather than the user.
Far pointer: If the program requires a lot of data, then a separate space is allocated for it outside the program data segment. So then a far pointer is used to access these memory locations so that the speed remains fast.
Huge pointer: In an 8086 family of processors, the max. Size of one data item can be 64k. But to override this default setup we can make use of huge pointers to have an object of size larger than 64k.
But I am curious to know that so the near pointer is allocated/ created by the system rather than the user.
Far pointer: If the program requires a lot of data, then a separate space is allocated for it outside the program data segment. So then a far pointer is used to access these memory locations so that the speed remains fast.
Huge pointer: In an 8086 family of processors, the max. Size of one data item can be 64k. But to override this default setup we can make use of huge pointers to have an object of size larger than 64k.
Satish birajdar said:
1 decade ago
far pointer refers to other code segment
near pointer refers to same code segment
near pointer refers to same code segment
Sowmya said:
1 decade ago
http://clanguagestuff.blogspot.com/2011/03/difference-between-far-and-huge.html
Its a real good reference.
Its a real good reference.
Goaku said:
1 decade ago
Can we leave such blank spaces while declearing variables?
Kiran said:
1 decade ago
Huge *far *near *ptr1---> is this a single variable?
If it is a single variable we should not use spaces in b/w the variables?
Can any one give me the explination please?
If it is a single variable we should not use spaces in b/w the variables?
Can any one give me the explination please?
Thamil said:
1 decade ago
Need proper clarification regarding this problem.
Bharath said:
1 decade ago
Please any one explain about this problem I did't get properly.
Vikas said:
1 decade ago
Thanks sowmy its really a good reference.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers