C Programming - Complicated Declarations - Discussion
Discussion Forum : Complicated Declarations - Find Output of Program (Q.No. 11)
11.
What will be the output of the program?
#include<stdio.h>
int main()
{
char huge *near *ptr1;
char huge *far *ptr2;
char huge *huge *ptr3;
printf("%d, %d, %d\n", sizeof(ptr1), sizeof(ptr2), sizeof(ptr3));
return 0;
}
Discussion:
13 comments Page 1 of 2.
Arvind said:
5 years ago
I am not getting this. Please explain me.
Nachiket R Rajput said:
6 years ago
Near is of 2 byte and far and huge are of 4 byte.
Kavya said:
6 years ago
I can't understand it. Please explain it.
Prarthana said:
7 years ago
I didn't understand. It gives an error message.
D:\class1\1\main.c|7|error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token|
D:\class1\1\main.c|5|error: 'near' undeclared (first use in this function)|
Please help me.
D:\class1\1\main.c|7|error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token|
D:\class1\1\main.c|5|error: 'near' undeclared (first use in this function)|
Please help me.
Anunita said:
7 years ago
Three types of pointer is there. Near, far and huge which consists of size 2, 4, 4 respectively.
Sindhu said:
8 years ago
How can you say that near contains only 2 bytes and far, huge contains 4 bytes?
Rajani sain said:
8 years ago
I didn't understand, please clarify the answer.
Mt_takeshi said:
9 years ago
This won't even compile according to C89, C99 or C11.
Anu said:
10 years ago
I didn't understand, please explain again?
PowerStar said:
1 decade ago
*ptr1 is of type near pointer hence the size is 2 bytes but whereas the *ptr2 and *ptr3 is of type far and huge pointers the size of huge and far pointers are 4 bytes.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers