-=

Beschreibung

Dies ist eine praktische Abkürzung, um eine Konstante oder eine Variable von einer Variablen abzuziehen.

Syntax

x -= y; // Äquivalent zum Ausdruck x = x - y

Parameter

  • x: Variable. Erlaubte Datentypen: int, float, double, byte, short, long.
  • y: Variable oder Konstante. Erlaubte Datentypen: int, float, double, byte, short, long.

Beispielcode

void setup() { Serial.begin(9600); int x = 20; x -= 2; // x enthält jetzt 18 Serial.print("x = "); Serial.println(x); } void loop() { }

Das ergebnis am seriellen monitor:

Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
Arduino Uno
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Uno' on 'COM15')
New Line
9600 baud
x = 18
Ln 11, Col 1
Arduino Uno on COM15
2

ARDUINO KAUFEMPFEHLUNG

Arduino UNO R3
Arduino Starter Kit
Bitte Beachten: Dies sind Partnerschaftslinks. Wenn Sie die Komponenten über diese Links Kaufen, können wir eine Provision erhalten, ohne weitere Kosten für Sie. Wir Schätzen es.

※ OUR MESSAGES