C Programming - Complicated Declarations - Discussion

Discussion Forum : Complicated Declarations - Find Output of Program (Q.No. 6)
6.
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, 4, 4
4, 4, 2
2, 4, 8
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
21 comments Page 1 of 3.

Manjulavani said:   2 decades ago
I want explanation about this problems.

Kishore said:   1 decade ago
Explanation please.

Ravikumar said:   1 decade ago
Give the explanation of the answer......

Suresh said:   1 decade ago
Any pointer will take size 4bits in 64 bit compiler, 2 bits in 32 bit compiler.

Pravin said:   1 decade ago
Please give the explanation about this problem.

Chintu said:   1 decade ago
Please explain about this problem, and also define huge, far, near.

Anil said:   1 decade ago
But how? can anyone explain this one.

Karthick said:   1 decade ago
near-2bit ...far and huge-4bit

far:sizeof(ptr1)-4 ... huge:sizeof(*ptr2)-4.... if it is

near:sizeof(*ptr3)-2 but here is near:sizeof(**ptr3)-4

Anurag.jnn@gmail.com said:   1 decade ago
ptr1 is a pointer to a far pointer for that the size is 4 in 32 and 64 bit compiler.

ptr2 is a pointer to a huge pointer for that the size is 4 in 32 and 64 bit compiler.

ptr3 is a pointer to a near pointer for that the size is 2 in 32 bit and 4 in 64 bit compiler.

Harsha said:   1 decade ago
What actually mean near, far and huge pointers ?


Post your comments here:

Your comments will be displayed after verification.