You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Language/Variables/Utilities/sizeof.adoc
+6-3Lines changed: 6 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -66,12 +66,15 @@ void loop() {
66
66
67
67
[float]
68
68
=== Notes and Warnings
69
-
Note that `sizeof` returns the total number of bytes. So for larger variable types such as ints, the for loop would look something like this.
69
+
Note that `sizeof` returns the total number of bytes. So for arrays of larger variable types such as ints, the for loop would look something like this.
70
70
71
71
[source,arduino]
72
72
----
73
-
for (i = 0; i < (sizeof(myInts)/sizeof(myInts[0])); i++) {
74
-
// do something with myInts[i]
73
+
int myValues[] = {123, 456, 789};
74
+
75
+
// this for loop works correctly with an array of any type or size
76
+
for (i = 0; i < (sizeof(myValues)/sizeof(myValues[0])); i++) {
0 commit comments