
- 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
廣告