xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

C language for(;;) All In One

C language for(;;) All In One

demo

for (;;) {
  // ...
}

https://github.com/torvalds/linux/blob/master/fs/pipe.c#L480

for(;;)

What is the for(;;) statement in the C language and how does it work?

It's a loop that lacks:
Initialization,
A condition, and
Update.

In other words, it's an infinite loop.

// infinite loop

https://www.quora.com/What-is-the-for-statement-in-the-C-language-and-how-does-it-work

c fof loop

for ( init; condition; increment )
{
   statement(s);
}

如果条件永远不为假,则循环将变成无限循环。
for 循环在传统意义上可用于实现无限循环。
由于构成循环的三个表达式中任何一个都不是必需的,您可以将某些条件表达式留空来构成一个无限循环。

#include <stdio.h>
 
int main () {
   for(;;) {
      printf("该循环会永远执行下去!\n");
   }
   return 0;
}

条件表达式不存在时,它被假设为

您也可以设置一个初始值和增量表达式,但是一般情况下,C 程序员偏向于使用 for(;;) 结构来表示一个无限循环

注意:您可以按 Ctrl + C 键终止一个无限循环。

https://www.runoob.com/cprogramming/c-loops.html

C / C++ (C Plus Plus) / C# (C Sharp)

.c, .cpp, .cs

https://github.com/xgqfrms/C

https://github.com/xgqfrms/C-plus-plus

https://github.com/xgqfrms/.Net

refs

https://www.runoob.com/cprogramming/c-tutorial.html



©xgqfrms 2012-2020

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2022-07-20 13:19  xgqfrms  阅读(19)  评论(0编辑  收藏  举报