- Pascal 教程
- Pascal - 主页
- Pascal - 概述
- Pascal - 环境设置
- Pascal - 程序结构
- Pascal - 基本语法
- Pascal - 数据类型
- Pascal - 变量类型
- Pascal - 常量
- Pascal - 运算符
- Pascal - 决策
- Pascal - 循环
- Pascal - 函数
- Pascal - 过程
- Pascal - 变量作用域
- Pascal - 字符串
- Pascal - 布尔值
- Pascal - 数组
- Pascal - 指针
- Pascal - 记录
- Pascal - 变体
- Pascal - 集合
- Pascal - 文件处理
- Pascal - 内存
- Pascal - 单元
- Pascal - 日期和时间
- Pascal - 对象
- Pascal - 类
- Pascal 有用资源
- Pascal - 快速指南
- Pascal - 有用资源
- Pascal - 讨论
Pascal - 指针的指针
指针的指针是多重间接寻址或指针链的一种形式。 通常,指针包含变量的地址。 当我们定义指针的指针时,第一个指针包含第二个指针的地址,该指针指向包含实际值得位置,如下所示。
一个指针的指针的变量必须如此声明。 例如,
type iptr = ^integer; pointerptr = ^ iptr;
以下示例将说明该概念以及显示地址 -
program exPointertoPointers;
type
iptr = ^integer;
pointerptr = ^ iptr;
var
num: integer;
ptr: iptr;
pptr: pointerptr;
x, y : ^word;
begin
num := 3000;
(* take the address of var *)
ptr := @num;
(* take the address of ptr using address of operator @ *)
pptr := @ptr;
(* let us see the value and the adresses *)
x:= addr(ptr);
y := addr(pptr);
writeln('Value of num = ', num );
writeln('Value available at ptr^ = ', ptr^ );
writeln('Value available at pptr^^ = ', pptr^^);
writeln('Address at ptr = ', x^);
writeln('Address at pptr = ', y^);
end.
当编译并执行以上代码时,将产生以下结果 -
Value of num = 3000 Value available at ptr^ = 3000 Value available at pptr^^ = 3000 Address at ptr = 45664 Address at pptr = 45680
pascal_pointers.htm
广告