C Programming - Complicated Declarations - Discussion
Discussion Forum : Complicated Declarations - Find Output of Program (Q.No. 4)
4.
What will be the output of the program (in Turbo C under DOS)?
#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:
32 comments Page 1 of 4.
Deepak said:
2 decades ago
Please explain this to me.
Mehul said:
1 decade ago
I don't understand. Please must be explain.
Suresh@pdtr said:
1 decade ago
Dear guys,
It's easy to remember,
as we can say when ever after (huge,far,near) declaration of a pointer variable it takes default sizes of huge, near, far.!
It's easy to remember,
as we can say when ever after (huge,far,near) declaration of a pointer variable it takes default sizes of huge, near, far.!
N n said:
1 decade ago
The code has syntax errors.
Kumar said:
1 decade ago
@NN
The above code works fine in Turbo C as said.
But in GCC it not works.
Is this due to platform dependency of C compiler?
Can you explain please?
The above code works fine in Turbo C as said.
But in GCC it not works.
Is this due to platform dependency of C compiler?
Can you explain please?
Sai said:
1 decade ago
it will consider the *far *ptr1---------------- * far 4bytes
*huge *ptr2--------------- *huge 4 bytes
*near *ptr3 -----------------near 2 bytess
*huge *ptr2--------------- *huge 4 bytes
*near *ptr3 -----------------near 2 bytess
Sarfraj said:
1 decade ago
I m not able to understand that, please give more explanation.
Seshan said:
1 decade ago
I can't understand can you explain me with full reference.
Somnath said:
1 decade ago
ptr1 is a pointer to a far pointer for that the size is 4
ptr2 is a pointer to a huge pointer for that the size is 4
ptr3 is a pointer to a near pointer for that the size is 2
ptr2 is a pointer to a huge pointer for that the size is 4
ptr3 is a pointer to a near pointer for that the size is 2
SandeepaSri said:
1 decade ago
Explanation please.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers