從頭開始製作程式語言/指標
外觀
指標是儲存其他變數地址的變數。此變數通常是 DWORD 或 32 位整數,但指標儲存地址的變數可以是任何型別。指標廣泛用於傳遞靜態或區域性變數以進行編輯,並且是提供給 void 函式的主要引數型別。
以下是宣告指標變數的傳統 C 和 C++ 格式。
[儲存指標值的變數型別][*(表示指標)][變數名][指標初始化][,|;]
注意,指標變數可以在它儲存值的變數型別中宣告。示例
float f1,f2,*p1,*p2=&f2;
& 運算子提供變數的地址,而不是儲存在其中的值。
該演算法如下
1. If character be * then go through following steps else skip it. 2. Get name of variable. 3. If next character not be = then write to .data section as [name of variable] ptr [type] ? 4. Else get value. Remove first character as it will be &. Write to .data? section as [name of variable] ptr [type] [value]. 5. Repeat step 1.
