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 2 of 4.
Rohit said:
1 decade ago
#include<stdio.h>
int main()
{
char huge *near *far *ptr1;
printf("%d %d\n", sizeof(***ptr1),sizeof(****ptr1));
return 0;
}
int main()
{
char huge *near *far *ptr1;
printf("%d %d\n", sizeof(***ptr1),sizeof(****ptr1));
return 0;
}
Ajay Paratmandali said:
8 years ago
Huge = 4.
Far = 4.
Near = 2.
Sizeoff
Ptr1-far *ptr1-near **ptr1-huge.
Ptr2-huge *ptr2-far **ptr2-near.
Ptr3-near *ptr3-huge **ptr3-far.
Far = 4.
Near = 2.
Sizeoff
Ptr1-far *ptr1-near **ptr1-huge.
Ptr2-huge *ptr2-far **ptr2-near.
Ptr3-near *ptr3-huge **ptr3-far.
Shubham Mittal said:
5 years ago
Far pointer size 32 bytes = 4 bit.
Huge pointer size 32 bytes = 4 bit.
Near pointer size 32 bytes = 2 bit.
So, the answer is= 4, 4, 2.
Huge pointer size 32 bytes = 4 bit.
Near pointer size 32 bytes = 2 bit.
So, the answer is= 4, 4, 2.
Priyanka said:
1 decade ago
Irrespective of pointer it declares far is of size 4,
Huge is of size 4,
Near is of size 2.
Huge is of size 4,
Near is of size 2.
Kavi said:
1 decade ago
What is the purpose of near, huge and far pointers. Explain with an example program?
Divya said:
9 years ago
Don't understand the concept of near far huge pointers. Help me by explaining this.
Nawaz said:
8 years ago
I am not getting how it is taking size? So please anyone explain this in detail.
Gautam A Naik said:
1 decade ago
But why is sizeof (ptr3) will give output as 2?. please explain me.
Deepika said:
1 decade ago
All the varibles have same type ouput is 4,4,4 but output is 4,4,2
Krishnaveni said:
9 years ago
I can't understand. It's so confusing. Please explain me clearly.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers