Yeah a classic case of use for a do ... while comes from manually implementing a function for converting a number to string. You always want at least one digit.
The first one could be simplified to:
Code:
do
{
if ( ! /* condition */)
break;
// ...
} while (true);
But you could also do it like this:
Code:
if (/* condition */)
do
{
// ...
} while (condition);
The assembly that actually gets generated goes as far as doing it like this:
Code:
goto loopend;
do
{
// ...
loopend:
} while (condition);
The second one:
Code:
// initialisation part
do
{
if (! /* condition */ )
break;
// ...
// next iteration part
} while (true);
For loops don't have to count over values. They can for example, walk over a linked list.