Go Down

Topic: impossible to do an infinity FOR loop (Read 254 times) previous topic - next topic

pYro_65

You don't have loop().
I added setup in to show how to use it. The code won't compile with a loop() as there are two functions with the same prototype. I just gave 3 different examples of the same recursive function.

UKHeliBob

Code: [Select]
 for(int a =0; true; a=a){
  }

Surely the whole point of a for loop is that is executed a predetermined number of times and that the variable is changed in a predictable way on each iteration.  If you want a never ending loop then as others have pointed out there are easier ways.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Robin2

By definition there can only be one infinite loop in a program so what's wrong with the one that comes free with the Arduino system - loop() ?

...R

Nick Gammon

Quote
By definition there can only be one infinite loop in a program ...
Executing at a time.

You may want to go into an infinite loop if you can't open an SD card file, for example, otherwise not.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Robin2

You may want to go into an infinite loop if you can't open an SD card file, for example, otherwise not.
loop() can easily be used for that

...R

Go Up