Iterating over all unsigned integers in a for loop

前端 未结 6 684
后悔当初
后悔当初 2020-12-07 01:09

Let\'s say I want to iterate over all integers in a for loop. For the sake of discussion, assume I am calling some unknown function f(unsigned x) f

6条回答
  •  时光说笑
    2020-12-07 01:48

    You could use another variable to detect when you've looped around.

    for (unsigned int i = 0, repeat = 0; !(i == 0 && repeat); i++, repeat = 1) {
        ...
    }
    

提交回复
热议问题