What is the difference between infinite while loops and for loops?

前端 未结 6 1755
忘掉有多难
忘掉有多难 2020-12-18 04:24

I see the different conventions used in many books I had read, where you would create infinite loops with either loop structure such as:

while()
   foo();
fo         


        
6条回答
  •  有刺的猬
    2020-12-18 04:59

    There's no difference.

    But

    while() foo();

    isn't the same that

    for(;;foo();)

    Remember! If you break the while before the foo() statement, foo() doesn't execute, but if you break the for, foo() executes...

提交回复
热议问题