Skip to content

Commit b0791f1

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 43176df commit b0791f1

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
@@ -70,7 +70,7 @@ Note that `sizeof` returns the total number of bytes. So for larger variable typ
7070

7171
[source,arduino]
7272
----
73-
for (i = 0; i < (sizeof(myInts)/sizeof(int)); i++) {
73+
for (i = 0; i < (sizeof(myInts)/sizeof(myInts[0])); i++) {
7474
// do something with myInts[i]
7575
}
7676
----

0 commit comments

Comments
 (0)