Skip to content

Commit 1a4095a

Browse files
committed
Add contents for Structure/Pointer Access Operators
1 parent 13349a7 commit 1a4095a

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
:source-highlighter: pygments
2+
:pygments-style: arduino
3+
:ext-relative: adoc
4+
5+
6+
= * Dereference Operator
7+
8+
9+
// OVERVIEW SECTION STARTS
10+
[#overview]
11+
--
12+
13+
[float]
14+
=== Description
15+
Dereferencing is one of the features specifically for use with pointers. The asterisk operator `*` is used for this purpose. If `p` is a pointer, then `*p` represents the value contained in the address pointed by `p`.
16+
[%hardbreaks]
17+
18+
--
19+
// OVERVIEW SECTION ENDS
20+
21+
22+
23+
// HOW TO USE SECTION STARTS
24+
[#howtouse]
25+
--
26+
27+
[float]
28+
=== Example Code
29+
30+
[source,arduino]
31+
----
32+
int *p; // declare a pointer to an int data type
33+
int i = 5, result = 0;
34+
p = &i; // now 'p' contains the address of 'i'
35+
result = *p; // 'result' gets the value at the address pointed by 'p'
36+
// i.e., it gets the value of 'i' which is 5
37+
----
38+
[%hardbreaks]
39+
40+
[float]
41+
=== Notes and Warnings
42+
Pointers are one of the complicated subjects for beginners in learning C, and it is possible to write the vast majority of Arduino sketches without ever encountering pointers. However for manipulating certain data structures, the use of pointers can simplify the code, and and knowledge of manipulating pointers is handy to have in one's toolkit.
43+
[%hardbreaks]
44+
45+
[float]
46+
=== See also
47+
48+
[role="language"]
49+
* #LANGUAGE# link:reference{ext-relative}[& Reference Operator]
50+
51+
[role="definition"]
52+
* #DEFINITION# http://en.wikipedia.org/wiki/Pointer_%28computer_programming%29[Pointers^]
53+
54+
--
55+
// HOW TO USE SECTION ENDS
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
:source-highlighter: pygments
2+
:pygments-style: arduino
3+
:ext-relative: adoc
4+
5+
6+
= & Reference Operator
7+
8+
9+
// OVERVIEW SECTION STARTS
10+
[#overview]
11+
--
12+
13+
[float]
14+
=== Description
15+
Referencing is one of the features specifically for use with pointers. The ampersand operator `&` is used for this purpose. If `x` is a variable, then `&x` represents the address of the variable `x`.
16+
[%hardbreaks]
17+
18+
--
19+
// OVERVIEW SECTION ENDS
20+
21+
22+
23+
// HOW TO USE SECTION STARTS
24+
[#howtouse]
25+
--
26+
27+
[float]
28+
=== Example Code
29+
30+
[source,arduino]
31+
----
32+
int *p; // declare a pointer to an int data type
33+
int i = 5, result = 0;
34+
p = &i; // now 'p' contains the address of 'i'
35+
result = *p; // 'result' gets the value at the address pointed by 'p'
36+
// i.e., it gets the value of 'i' which is 5
37+
----
38+
[%hardbreaks]
39+
40+
[float]
41+
=== Notes and Warnings
42+
Pointers are one of the complicated subjects for beginners in learning C, and it is possible to write the vast majority of Arduino sketches without ever encountering pointers. However for manipulating certain data structures, the use of pointers can simplify the code, and and knowledge of manipulating pointers is handy to have in one's toolkit.
43+
[%hardbreaks]
44+
45+
[float]
46+
=== See also
47+
48+
[role="language"]
49+
* #LANGUAGE# link:dereference{ext-relative}[* Dereference Operator]
50+
51+
[role="definition"]
52+
* #DEFINITION# http://en.wikipedia.org/wiki/Pointer_%28computer_programming%29[Pointers^]
53+
54+
--
55+
// HOW TO USE SECTION ENDS

0 commit comments

Comments
 (0)