Inside Delphi 2006 (Wordware Delphi Developers Library)

You shouldn't try to use the P pointer yet because it isn't initialized. When a pointer is not initialized, it points to an invalid memory location. Trying to use a pointer that points to an invalid memory location is like trying to bungee jump with your pockets full of nitroglycerine vials. Not a pleasant experience, to say the least.

To initialize a pointer, you have to assign it a memory address. To read the address of a variable, you can use the @ operator or the Addr function:

P := Addr(I); P := @I;

The P pointer now points to the memory location of the I variable. If you want to know the exact memory location of the I variable, typecast the pointer to an integer and display it:

P := @I; WriteLn(Integer(P));

Категории