Address of a variable

From Rosetta Code
Revision as of 14:46, 27 February 2007 by 209.63.105.137 (talk)
Task
Address of a variable
You are encouraged to solve this task according to the task description, using any language you may know.

Demonstrate how to get the address of a variable and how to set the address of a variable.

Ada

Get The Address

The_Address : System.Address;
I : Integer;
The_Address := I'Address;

Set The Address

Set the address of a variable to address A100 in hexidecimal

I : Integer;
for I'Address use 16#A100#;

Set the address of one varible to the address of another variable, creating an overlay.

I : Integer;
J : Integer;
For I'Address use J'Address;

Perl

Interpreter: Perl 5.x

In Perl there is no reason for doing this. The internal memory addresses are handled by Perl, so the programmer doesn't need to worry about it at all.