Re: Any chance of a solution?
"[...] where the test is at the top of the loop. "
IIRC Pascal always executed a FOR loop once - even if the condition suggested the limit had already been reached. One of the Pascal "Common 10 mistakes" when moving to it from another language.
Always felt that "C" could have done with := rather than = for assignment. That would have prevented the = and == mistakes in C.