C Programming on the IBM PC (C Programmers Reference Guide Series)
|
|
while
The while loop has the general form:
while(condition) { statement block }
If a single statement is the object of the while, then the braces may be omitted. The while loop iterates as long as condition is true.
The while tests the condition at the top of the loop. Therefore, if the condition is false to begin with, the loop will not execute even once. The condition may be any expression.
The following is an example of a while loop. It will read 100 characters and store them into a character array.
char s[256]; t = 0; while(t<100) { s[t] = stream.get(); t++; }
|
|