Micha W. schrieb:
> int song;
> int dance;
> void loop() {
> if (song = 1) {
> dance = 1;
> }
> song = 1;
> }
>
> Kann das so? :P
Erstmal ist das miserabel eingerückt.
1 | int song;
|
2 | int dance;
|
3 |
|
4 | void loop()
|
5 | {
|
6 | if(song = 1)
|
7 | {
|
8 | dance = 1;
|
9 | }
|
10 | song = 1;
|
11 | }
|
Zudem ist die Variable song überflüssig.
1 | int dance;
|
2 | void loop()
|
3 | {
|
4 | dance = 1;
|
5 | }
|
Da dance nur auf 1 gesetzt wird, kann man sich auch sparen, das in der
loop zu tun.
1 | int dance = 1;
|
2 | void loop()
|
3 | {
|
4 |
|
5 | }
|
Da das Programm nur aus der loop besteht und in der loop nichts gemacht
wird, braucht man überhaupt keine Variablen.
Da das Programm nichts macht, kann man sich das ganz schenken.
Micha W. schrieb:
> Kann das so?
Nein, das gibt nur Mecker vom Compiler wegen
1 | if (song = 1)
|
2 | {
|
3 | //...
|
4 | }
|
5 |
|
6 | warning: suggest parantheses...
|