当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


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大神的英文原创作品 &。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。