What does for(;;) mean?

angryTom
Release: 2019-10-23 16:54:27
Original
25317 people have browsed it

What does for(;;) mean?

What does for(;;) mean?

The meaning of an infinite loop is to always execute the content in the loop body. . Because there is no specified condition for the loop to end, the program will continue to execute and generate an infinite loop.

Analysis:

for(i=0; i<10; i++) {}
Copy after login

i=0 is to give i an initial value

i<10 is the judgment condition

i is the statement that ends this loop

The first one is empty, we can give i a value before, for example

int i = 0;
for(; i<10; i++) {}
Copy after login

The second one is empty. No judgment condition

The third one is empty, that is, there is no statement to drive the end of the loop.

The above expression is completely equivalent to the following

int i = 0;
WHILE(1){
    i++;
}
Copy after login

That is, if all three are omitted The loop body loops forever.

Recommended course: C language tutorial

The above is the detailed content of What does for(;;) mean?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template