単項*演算子

名称

単項*演算子

説明

デリファレンス(参照外し)は、特にポインタと一緒に使われる機構である。単項*演算子はこのために使われる。ポインタpに対して、*pはポインタpの示すアドレスの内容を示す。

使用例

1
2
3
4
5
6
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のスケッチは、ポインタを使わずに書くことができる。しかし、ある種のデータ構造の操作にポインタを使うとコードが簡潔になるし、ツールキットの中では、ポインタ操作の知識が役にたつ。

参照

定義 ポインタ

オリジナルのページ

https://www.arduino.cc/reference/en/language/structure/pointer-access-operators/dereference/

Last Revision: 2019/06/25

最終更新日

January 4, 2024

inserted by FC2 system