Pointers [ SPL to HP C/XL Migration Guide ] MPE/iX 5.0 Documentation
SPL to HP C/XL Migration Guide
Pointers
Table 3-20. Pointers
---------------------------------------------------------------------------------------------
| | |
| SPL | HP C/XL Equivalent |
| | |
---------------------------------------------------------------------------------------------
| | |
| Type: Pointer to simple data type | Type: Pointer to simple data type |
| | |
---------------------------------------------------------------------------------------------
| | |
| A pointer is a 16-bit word containing the | A pointer is a 32-bit word containing the |
| address of another data item. | address of another data item. |
| | |
---------------------------------------------------------------------------------------------
| | |
| A pointer is declared with the reserved | A pointer is declared by preceding its |
| word POINTER. | identifier with the "*" unary operator. |
| | |
---------------------------------------------------------------------------------------------
| | |
| A pointer is dereferenced when its | A pointer is dereferenced by preceding its |
| identifier is used alone. | identifier with the "*" unary operator. |
| | |
---------------------------------------------------------------------------------------------
| | |
| The value of a pointer is referenced by | The value of a pointer is referenced by |
| preceding its identifier with the "@" unary | using its identifier alone. |
| operator. | |
| | |
---------------------------------------------------------------------------------------------
| | |
| The address of a data item is obtained by | The address of a data item is obtained by |
| preceding its identifier with the "@" unary | preceding its identifier with the "&" unary |
| operator. | operator. |
| | |
---------------------------------------------------------------------------------------------
Example:
SPL: HP C/XL:
INTEGER POINTER ptr; short int *ptr; declares ptr as pointer to integer
@ptr := @ivar; ptr = &ivar; assigns address of ivar to ptr
ptr := 3; *ptr = 3; stores 3 in ivar (addressed by ptr)
ptr := ptr + 1; *ptr = *ptr + 1;increments ivar
va1 := ptr; va1 = *ptr; stores value from ivar into va1
MPE/iX 5.0 Documentation