Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • C
for (size_t i = 0; i < sizeof(items) / sizeof(items[0]); i++) {
	DoSomethingWith(&items[i]);
}

sizeof the array divided by the size of the first element computes the number of elements, often defined as macro ARRAY_SIZE
for (unsigned int i = 0 ; i < items_length ; ++i){
        Item* x = &(items[i]);
	DoSomethingWith(x);
}

items_length type is: unsigned int
DoSomethingWith prototype is: void DoSomethingWith(Item*);
for Item of Items loop
   Do_Something (Item);
end loop;

New implementation...