Hi
I found this command : for(;;);
in this program:
if (!SD.begin(chipSelect)) {
Serial.println("Erreur de carte SD !");
for(;;);
}
I don't understand this command : for(;;);
Usually i use return
Is it better than return(for void) ??
thanks
Hi
I found this command : for(;;);
in this program:
if (!SD.begin(chipSelect)) {
Serial.println("Erreur de carte SD !");
for(;;);
}
I don't understand this command : for(;;);
Usually i use return
Is it better than return(for void) ??
thanks
It is an infinite loop, just "hangs".
I found this command : for(;;);
I very much doubt it.
You probably found
for(;;);
Note how the use of code tags stops some parts of code being interpreted as HTML commands
Please use them in future when posting code
for (A ; B ; C) D;
is roughly equivalent to:
A;
while (B)
{
D;
C;
}
The 'for' loop can have a missing 'B' but you can't have a "while ()" (syntax error) and treating a missing 'B' as 'false' would mean that the loop would never happen (which is useless) so they treat a missing 'B' as 'true'
The special case of:
for (;;);
is roughly equivalent to:
while (true);
In other words: an infinite loop that does nothing.
In other words: an infinite loop that does nothing.
Or everything.
Used in C as the equivalent of the Arduino loop() function.
loop() {
//Your code here
}
Is the same as:
for (;;) {
//Your code here
}
PerryBebbington:
Or everything.
Used in C as the equivalent of the Arduino loop() function.
Indeed. Look at how loop() is implemented in the core:
for (;;) {
loop();
if (serialEventRun) serialEventRun();
}
Yes, it's for(;;); like the subject
thank you all, i understand better now.
fcfranck:
Yes, it's for(;;); like the subjectthank you all, i understand better now.
...except for the part about how to use code tags, reply #2