_FP_OFF, _FP_SEG

Description

Get or set a far-pointer offset (_FP_OFF) or a far-pointer segment (_FP_SEG).

#include <dos.h>

unsigned _FP_OFF( void __far *address );

unsigned _FP_SEG( void __far *address );

address Far pointer to memory address  

Remarks

The _FP_OFF and _FP_SEG macros can be used to set or get the offset and segment, respectively, of the far pointer at address.

Return Value

The _FP_OFF macro returns an offset. The _FP_SEG macro returns a segment address.

Compatibility

Standards:None

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:None

Example

/* _FP_SEG.C: This program uses _FP_SEG and _FP_OFF to obtain

* the segment and offset of the long pointer p.

*/

#include <dos.h>

#include <malloc.h>

#include <stdio.h>

void main( void )

{

void __far *p;

unsigned int seg_val;

unsigned int off_val;

p = _fmalloc( 100 ); /* Points pointer at something */

seg_val = _FP_SEG( p ); /* Gets address pointed to */

off_val = _FP_OFF( p );

printf( "Segment is %.4X; Offset is %.4X\n", seg_val, off_val );

}

Output

Segment is 00C7; Offset is 0016