Forum: Compiler & IDEs for schleife eintrittsbedingung


von Großes F. (112)


Lesenswert?

hi,

wird eine for-Schleife immer mindestens einmal ausgeführt, auch dann, 
wenn die Abbruchbedingung von Anfang an erfüllt ist?

for(uint8_t j=0; j<0; j++)
{
mache();
}

Wrid mache(); einmal aufgerufen oder nicht?

von DirkB (Gast)


Lesenswert?

Nein, sollte es nicht.
Aber wie soll denn bitte ein unsigned kleiner als 0 werden?

von Stefan B. (stefan) Benutzerseite


Lesenswert?

Nicht.

[zitat ISO/IEC 9899:TC2 Committee Draft — May 6, 2005 WG14/N1124]
6.8.5.3 The for statement
The statement for ( clause-1 ; expression-2 ; expression-3 ) statement 
behaves as follows:
The expression expression-2 is the controlling expression that is 
evaluated before each execution of the loop body...
[/zitat]

von Großes F. (112)


Lesenswert?

danke

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.