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.
Sindhu said:
10 years ago
How can you say that near contains only 2 bytes and far, huge contains 4 bytes?
(1)
Malathi said:
1 decade ago
The near have the 2 byte values, far and huge have 4 byte values.
Peheli said:
1 decade ago
I didn't understand, please clarify the answer.
Krishna said:
1 decade ago
What about the * an ptr. ?
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.
Anu said:
1 decade ago
I didn't understand, please explain again?
Mt_takeshi said:
1 decade ago
This won't even compile according to C89, C99 or C11.
Rajani sain said:
10 years ago
I didn't understand, please clarify the answer.
Anunita said:
9 years ago
Three types of pointer is there. Near, far and huge which consists of size 2, 4, 4 respectively.
Prarthana said:
8 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.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers