Code: Select all
uint32_t array[16];
foreach (p in array) {
*p = (uint32_t)0
}
foreach (p in "Hello World!!") {
put(*p);
}
No pointer declaration needed, no need to know the size of the array, no need to use macros for the array size and other tricks, no confusion between 0 and 1 as base and < or <= as relation.
- Iterating on a scalar type is like iterating on an array of size 1.
- The pointer is implicitly a pointer to the array element type but constant, it is not modifiable.
- Element index can be obtained using pointer arithmetic (p - array).
Giovanni