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 2 of 6.
Kavipriya said:
8 years ago
What is the output in turboc compiler and Linux compiler?
#include<stdio.h>
main(){
int x=65,y=97;
if('x'>'y')
Print("A");
Print("B");
}
I don't know what concept is there if anyone know that concept can you post the answer friends.
#include<stdio.h>
main(){
int x=65,y=97;
if('x'>'y')
Print("A");
Print("B");
}
I don't know what concept is there if anyone know that concept can you post the answer friends.
Rprabaraj said:
8 years ago
What is mean by segment and offset value? Explain me, please.
Baahubali said:
8 years ago
What is offset and segment in this case?
Jaya phanindra said:
8 years ago
While compiling the given code am getting the below error.
Can anyone explain this please.
Error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token.
Can anyone explain this please.
Error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token.
Yuvasree said:
8 years ago
I am getting error in 32bit Linux compiler, s2 and s3 was declared. Why I'm getting this error in 32 bit compiler?
Muthu said:
8 years ago
What is far, hug and why it has 4bytes?
Sri said:
9 years ago
Why should we consider 4 for both far and huge?
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.
Ganga said:
9 years ago
What is meant by far and huge? I don't understand. Please explain.
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).
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers