title: Is there ever a need for a "do {...} while ( )" loop?
body: <p>Bjarne Stroustrup (C++ creator) once said that he avoids &quot;do/while&quot; loops, and prefers to write the code in terms of a &quot;while&quot; loop instead. [See quote below.]</p>
  <p>Since hearing this, I have found this to be true.  What are your thoughts?  Is there an example where a &quot;do/while&quot; is much cleaner and easier to understand than if you used a &quot;while&quot; instead?</p>
  <p>In response to some of the answers: yes, I understand the technical difference between &quot;do/while&quot; and &quot;while&quot;.  This is a deeper question about readability and structuring code involving loops.</p>
  <p>Let me ask another way: suppose you were forbidden from using &quot;do/while&quot; - is there a realistic example where this would give you no choice but to write unclean code using &quot;while&quot;?</p>
  <p>From &quot;The C++ Programming Language&quot;, 6.3.3:</p>
  <blockquote>
  <p>In my experience, the do-statement is a source of errors and confusion.  The reason is that its body is always executed once before the condition is evaluated.  However, for the body to work correctly, something very much like the condition must hold even the first time through.  More often than I would have guessed, I have found that condition not to hold as expected either when the program was first written and tested, or later after the code preceding it has been modified.  <strong>I also prefer the condition &quot;up front where I can see it.&quot;  Consequently, I tend to avoid do-statements.</strong> -Bjarne</p>
  </blockquote>
  <p>Avoiding the do/while loop is a recommendation included in the <a href="https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md" rel="noreferrer">C++ Core Guidelines</a> as <a href="https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es75-avoid-do-statements" rel="noreferrer">ES.75, avoid do-statements</a>.</p>