當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Arduino &用法及代碼示例

[指針訪問運算符]

說明

引用是專門用於指針的函數之一。與號運算符& 用於此目的。如果 x 是變量,則 &x 表示變量 x 的地址。

示例代碼

int *p;       // declare a pointer to an int data type
int i = 5;
int result = 0;
p = &i;       // now 'p' contains the address of 'i'
result = *p;  // 'result' gets the value at the address pointed by 'p'
              // i.e., it gets the value of 'i' which is 5

注意事項和警告

指針是初學者學習 C 的複雜科目之一,可以在沒有遇到指針的情況下編寫絕大多數 Arduino 草圖。但是對於操作某些數據結構,使用指針可以簡化代碼,並且操作指針的知識在一個人的工具包中很方便。

相關用法


注:本文由純淨天空篩選整理自arduino.cc大神的英文原創作品 &。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。