Skip to content

Commit 5133643

Browse files
committed
Use best practices for determining the size of an array element
The previous code does not automatically adapt to changes in the type of myInts.
1 parent 2a1abdc commit 5133643

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Language/Variables/Utilities/sizeof.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Note that `sizeof` returns the total number of bytes. So for larger variable typ
7878

7979
[source,arduino]
8080
----
81-
for (i = 0; i < (sizeof(myInts)/sizeof(int)); i++) {
81+
for (i = 0; i < (sizeof(myInts)/sizeof(myInts[0])); i++) {
8282
// do something with myInts[i]
8383
}
8484
----

0 commit comments

Comments
 (0)