What is
offset address?
Offset address and segment
number in c programming language
Each segment has divided into two parts.
1. Segment no (4 bit)
2. Offset address (16 bit)
So, in the other words we can say memory address of any variable in c has two parts segment number and offset address.
In turbo c 3.0 a particular segment number offset
address varies from 0x0000 to 0xFFFF
Suppose physical address of any variable in c is
0x500F1.
Then
its segment number is 5 and offset address is 00F1.
Write a program to find the offset address of any
variable?
#include<stdio.h>
int main(){
int x;
printf("%u ",&x); //To
print offset address
printf("%p ",x);
//To print segment address
printf("%p ",&x);
//To print offset address
printf("%fp ",&x);
//To print segment address : offset address
return 0;
}
8 comments:
wow it is the best tutorials that i ever seen!!! respect!!!!
Thanks a lot for clear explanation!!
floating point not linked for the last one.
best best best tutorials i have ever wanted.
study co
Very good tutorial. Intact best tutorial I have ever seen
Really amazing.what a depth u r carrying.
Thank you a lot:-)
Damn!! You haven't explained what's that "offset" literally means. You should have explained to us why the term "offset" is used in computer memory terminology. How the "offset" matters to us. Why should we take it into consideration, while programming?
Post a Comment