do/while command (C and C++)

The do/while command performs a command before evaluating the test expression. Due to this order of execution, the command is performed at least once. The do and while keywords must be lowercase and cannot be abbreviated.

Read syntax diagramSkip visual syntax diagram
>>-do--command--while--(--expression--)--;---------------------><

command
A valid Debug Tool command.
expression
A valid Debug Tool C and C++ expression.

The body of the loop is performed before the while clause (the controlling part) is evaluated. Further execution of the do⁄while command depends on the value of the while clause. If the while clause does not evaluate to false, the command is performed again. Otherwise, execution of the command ends.

A break command can cause the execution of a do⁄while command to end, even when the while clause does not evaluate to false.

Usage note

The do/while command cannot be used while you replay recorded statements by using the PLAYBACK commands by using the PLAYBACK command.

Example

The following command prompts you to enter a 1. If you enter a 1, the command ends execution. Otherwise, the command displays another prompt.
int reply1;

do {
  printf("Enter a 1.\n");
  scanf("%d", &reply1);
} while (reply1 != 1);