C++ is one of the many things I don't know
I also didn't understand the "right to left in the array" comment. Arrays have a lower bound(s) and upper bound(s)
Here's some VBA loop-ology examples that you might be able to use
Option Explicit
Sub cPlusPlus()
Dim i As Long
Dim pos As Variant
pos = Array(1, 2, 3, 4, 5, 0, 6, 7, 8, 9)
'case 1
For i = LBound(pos) To UBound(pos)
Debug.Print "Case 1", i, pos(i)
Next
'case 2
For i = LBound(pos) To UBound(pos)
If pos(i) = 0 Then Exit For
Debug.Print "Case 2", i, pos(i)
Next
'case 3
i = LBound(pos)
Do While pos(i) <> 0 And i <= UBound(pos)
Debug.Print "Case 3", i, pos(i)
i = i + 1
Loop
'case 4
i = LBound(pos)
Do
Debug.Print "Case 4", i, pos(i)
i = i + 1
Loop Until pos(i + 1) = 0 Or i = UBound(pos)
End Sub