Name

while

Synopsis

The while statement is a “top-driven” loop: first the loop condition (i. e., the controlling expression) is evaluated. If it yields “true”, the loop body is executed, and then the controlling expression is evaluated again. If it is false, program execution continues with the statement following the loop body.

Syntax:

while ( expression )  statement

Example:

s = str;           // Let the char pointer s  
while( *s != '\0') // point to the end of str 
    ++s;

Get C Pocket Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.