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;
}
4, 4, 4
2, 2, 2
2, 8, 4
2, 4, 8
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
31 comments Page 2 of 4.

Jayshree said:   10 years ago
I am confused about output can you explain anyone again!

Riya said:   10 years ago
If near pointer is 2 byte then why the output is 4 byte for ptr 2.

Meerb said:   1 decade ago
Please me the answer of this question please.

What will be the size of a pointer, pointing to an object of size 1MB?

Pavan said:   1 decade ago
Exp: far, near and huge pointer are used in dos only. Because there is only one mb memory for accessing. 1mb memory is divided into segment.

There are various segment like cs(code segment), ss(stack segment), ds(data segment) and more like extra segment etc.

Such type of pointer are used to access the memory.

Sumasree said:   1 decade ago
It's supports multiple languages and also portable runs on all available platforms and free s/w, but turbo C don't have these all.

Naseeb said:   1 decade ago
What is GCC compiler?

Jaswanth said:   1 decade ago
Any pointer holds 4 bytes of memory in gcc compiler.

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.

Arun said:   2 decades ago
Confused about these near, far, huge pointers.

Can anyonre explain this concept?.

Abhijit_softlove said:   1 decade ago
char x *y *z *ptr; / x y &z near huge or far

sizeof(ptr)= sizeof(z)
sizeof(*ptr)= sizeof(y)
sizeof(**ptr)= sizeof(x)


Post your comments here:

Your comments will be displayed after verification.