5.6.3.2. Do-Loops

A do-loop differs from a while loop in two key points. First, its body is performed one or more times. Second, the test that determines whether to do the loop body again is done at the bottom of the loop instead of at the top. The general form is

  do
  {
    statements
  } while (condition);
If the condition is true (or nonzero) at the end of the loop, the loop body is done again, and it keeps being repeated until the condition is found to be false (0). For example,
  int n;
  char c;
  do
  {
     // Read a character and store it in c.  n is set to
     // the number of items successfully read.

     n = scanf("%c", &c);
     if(n != 0)
     {
       printf("%c", c);
     }
  } while(n != 0);
copies the standard input to the standard output.