What is offset address

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;
}






C tutorial home.

8 comments:

ANtony said...

wow it is the best tutorials that i ever seen!!! respect!!!!

Anonymous said...

Thanks a lot for clear explanation!!

mrigendra said...

floating point not linked for the last one.

The unfortunate man said...

best best best tutorials i have ever wanted.

Unknown said...

study co

Unknown said...

Very good tutorial. Intact best tutorial I have ever seen

Unknown said...

Really amazing.what a depth u r carrying.
Thank you a lot:-)

Shashi said...

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?