How does the semicolon work at the beginning of “for”?

后端 未结 2 781
执念已碎
执念已碎 2021-01-05 14:15

I just came across this code on the Mozilla site and, while to me it looks broken, it\'s likely I am not familiar with its use:

for (; k < len; k++)
    {         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-05 14:55

    it's mean that declaration and initialization k variable is something upper;

    If you want skip some for section, you just put semicolon, e.g.:

    for (;;) {
      //infinite loop
    }
    

提交回复
热议问题