Go Down

Topic: if vergleich funktioniert nicht (Read 522 times) previous topic - next topic

Hallo Community,

ich habe in meinem Code einen if-Vergleich, der jedoch nicht funktioniert.
Woran kann das liegen? Was mache ich falsch?

Code: [Select]
void writeOutput(char OutString[])
{
  /*set Output on Rainbowduino*/
  char *p = OutString;
  char *str;
 
  while ((str = strtok_r(p, "-", &p)) != NULL)
  {
    lcd.clear();
    delay(500);
    Serial.println(str);
    if (str == "PF")
    {
      lcd.write(2);
      lcd.write(2);
    }
    else if (str == "GG")
    {
      lcd.write(1);
      lcd.write(1);
    }
    else if(str=="90")
    {
      lcd.write(3);
      lcd.write(3);
    }
    else
    {
      lcd.print(str);
    }
   
    /*delay(2000);*/
   
    /*Write str to Rainbowduino*/
    delay(500);
  }
}


Viele Grüße
Basti

michael_x

if (str == "GG")

vergleicht zwei Pointer, die nie gleich sein werden...

du suchst nach strcmp


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy