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 4 of 6.
Arpita said:
1 decade ago
Can anybody answer the meaning of huge and far in detail?
Pooja said:
10 years ago
Can anybody explain huge pointer in detail?
Sai said:
9 years ago
I can't understood. Anyone can explain in details. Please.
Saranya said:
9 years ago
What is 16-bit segment value and 16-bit offset value?
Satya said:
9 years ago
The far and huge have the same value.
Arun said:
9 years ago
On C compilers targeting the 8086 processor family, far pointers were declared using a non-standard far qualifier.
Far is not a standard keyword. Most of the compilers will raise error with far and huge qualifiers but compilers for 8086 processor family might not. It is used with pointers for memory segmentation. Its has two parts segment value and offset value (memory location within that segment).
Far is not a standard keyword. Most of the compilers will raise error with far and huge qualifiers but compilers for 8086 processor family might not. It is used with pointers for memory segmentation. Its has two parts segment value and offset value (memory location within that segment).
Ganga said:
9 years ago
What is meant by far and huge? I don't understand. Please explain.
Rahul Manjramkar said:
9 years ago
What is the far and huge?
And this code is error can't show output, so please explain in detail program also.
And this code is error can't show output, so please explain in detail program also.
Sri said:
9 years ago
Why should we consider 4 for both far and huge?
Muthu said:
8 years ago
What is far, hug and why it has 4bytes?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers