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;
}
Discussion:
21 comments Page 2 of 3.
SUHAS T M said:
1 decade ago
Pointer is used to store the address of int, char, float so no matter what the data type is. It stores the address value which is an integer value so it requires 2 byte in 16 bit compiler and 4 byte in 32 bit compiler.
Manjulavani said:
2 decades ago
I want explanation about this problems.
Harsha said:
1 decade ago
What actually mean near, far and huge pointers ?
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.
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.
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
far:sizeof(ptr1)-4 ... huge:sizeof(*ptr2)-4.... if it is
near:sizeof(*ptr3)-2 but here is near:sizeof(**ptr3)-4
Anil said:
1 decade ago
But how? can anyone explain this one.
Chintu said:
1 decade ago
Please explain about this problem, and also define huge, far, near.
Pravin said:
1 decade ago
Please give the explanation about this problem.
Suresh said:
1 decade ago
Any pointer will take size 4bits in 64 bit compiler, 2 bits in 32 bit compiler.
Ravikumar said:
1 decade ago
Give the explanation of the answer......
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers