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.
Kamesh said:
1 decade ago
Can any body tell me what does mean by
char far *s2;
char huge *s3;
char far *s2;
char huge *s3;
SALVATOR said:
1 decade ago
char far *s2;
char huge *s3;
WHAT IS THE ROLE OF *S2 AND *S3 ?
char huge *s3;
WHAT IS THE ROLE OF *S2 AND *S3 ?
Ganga said:
9 years ago
What is meant by far and huge? I don't understand. Please explain.
Amol said:
6 years ago
@Sirji if you used * as like above example then you got an error.
Rprabaraj said:
8 years ago
What is mean by segment and offset value? Explain me, please.
Sai said:
9 years ago
I can't understood. Anyone can explain in details. Please.
Sri said:
1 decade ago
Can any one give the answer what is meant by far and huge?
Arpita said:
1 decade ago
Can anybody answer the meaning of huge and far in detail?
Neethu said:
1 decade ago
Explain, in which cases we were used these far and huge ?
Ani said:
7 years ago
I don't know what is far and huge here, Can you explain?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers