|Just depends on the phase of the moon or how I'm feeling at the time! |
No worries :+) I didn't mean it to come across as criticism, it really is just my preference, others may like it and adopt it for their code, especially if they are a beginner.
It is incumbent on me to mention the reality of where I stand in terms of experience & knowledge: I first taught myself C from K&R in 1988 (no internet, just me & the book!) on a Sparc Station 1* Unix machine, and have a been a hobby programmer since, with some exposure to other languages through university & work. But I gather that you have a degree and have been a developer for more than 3 decades, so your knowledge and experience is vastly superior. So I always look forward to any code & advice you provide to anyone :+)
|Variables defined inside the body of a do loop can't be used in the condition! Their scope is up-to the do body closing } before the while...|
This just proves that I can screw things up just as well as anyone !!
Thinking about that a bit more, what about a variable declared before the do loop; some calcs are done in the body; then that value is part of the while condition? I guess I am trying to think of other situations where a do loop is justified, I am sure there are plenty of them.
* It was a high end machine in those days: Sun Sparc Station 1, 32 bit, a whopping 8Mb Ram, I don't remember how much disk space, we had a carousel pen plotter, and a quite good CAD system with 20 inch colour screen. The rest of the plebs had DOS 3.0 with 640Kb & 10MB disk, some of the fancy pants had DOS 6.0 with 1MB ram, although they didn't realise they weren't using all of it because they didn't run HIMEM.SYS !!