!=

Beschreibung

Vergleicht die linke Variable mit dem Wert oder der Variablen rechts vom Operator. Gibt true zurück, wenn die beiden Operanden nicht gleich sind.

Syntax

x != y; // Ist false, wenn x gleich y ist und true, wenn x nicht gleich y ist

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 = 1; int y = 2; if (x != y) // Prüft, ob x nicht gleich y ist Serial.println("x is NOT equal to y"); else Serial.println("x is equal to y"); } 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 is NOT equal to y
Ln 11, Col 1
Arduino Uno on COM15
2

Siehe Auch

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