C Programming - Declarations and Initializations - Discussion
Discussion Forum : Declarations and Initializations - Find Output of Program (Q.No. 4)
4.
What is the output of the program in Turbo C (in DOS 16-bit OS)?
#include<stdio.h>
int main()
{
char *s1;
char far *s2;
char huge *s3;
printf("%d, %d, %d\n", sizeof(s1), sizeof(s2), sizeof(s3));
return 0;
}
Answer: Option
Explanation:
Any pointer size is 2 bytes. (only 16-bit offset)
So, char *s1 = 2 bytes.
So, char far *s2; = 4 bytes.
So, char huge *s3; = 4 bytes.
A far, huge pointer has two parts: a 16-bit segment value and a 16-bit offset value.
Since C is a compiler dependent language, it may give different output in other platforms. The above program works fine in Windows (TurboC), but error in Linux (GCC Compiler).
Discussion:
55 comments Page 5 of 6.
Laxman said:
6 years ago
Sir every pointer has 2 bytes so how *s2, *s3 4 bytes?
Saraswathi said:
1 decade ago
Then what is huge pointer? is it same as far pointer.
Saranya said:
9 years ago
What is 16-bit segment value and 16-bit offset value?
Ranjith said:
2 decades ago
I don't know what is far and huge. Can you explain?
Kavita.C.Karjagar said:
1 decade ago
1.Explain what is far and huge?
2.were it is used?
2.were it is used?
Aruna said:
1 decade ago
Can anyone explain in detail about far and huge?
Sri said:
9 years ago
Why should we consider 4 for both far and huge?
Rohit said:
1 decade ago
How is the answer is 2, 4, 4 explain in depth ?
Pooja said:
10 years ago
Can anybody explain huge pointer in detail?
Baahubali said:
8 years ago
What is offset and segment in this case?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers