Address of a variable: Difference between revisions

From Rosetta Code
Content added Content deleted
(New page: {{task}} Demonstrate how to get the address of a variable and how to set the address of a variable. ==Ada== Category:Ada ===Get The Address=== The_Address : System.Address; I : ...)
 
No edit summary
Line 16: Line 16:
J : Integer;
J : Integer;
For I'Address use J'Address;
For I'Address use J'Address;

==[[Perl]]==
[[Category: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.

Revision as of 14:46, 27 February 2007

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.