Not only what Tim said, but (and my CPP is a little rusty) you can do something like this:
struct {
int val1;
int val2;
} myStruct;
myStruct[] myStructArray;
for (int *ptr = &myStructArray; ptr <= &myStructArray[lastElem]; ptr+=sizeof(myStruct))
{
}
May not be compilable, but you get the point. For loops don't necessarily use "counters", they use iterators. You can do some pretty strange stuff with while loops:
for (bool flag = false;flag;)
{
}
for (;;)
{
}
Etc... The for loop is just an initialization, condition, and a statement that runs every time it loops (which is
typically used for iteration or counting.
So writing out what a "for" loop means:
for (initial condition) until (condition is true) do (for body) then (increment variable)
Which in its compact form, becomes:
for (initial condition; exit condition; increment variable)
{
method body
}
So its not called "counter controlled loop" because its not necessarily controlled by a counter, Its still a condition check (strangely enough, compilers turn For loops into while loops, so you can do the same with while loops as for loops and vice versa).