void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
char string1[ ] = "left";
char string2[ ] = "right";
if (strcmp(string1, string2) == 0)
{
Serial.println("strings are equal");
delay(100);
}
if (strcmp("left", "leftcenter") == 0) // this will evaluate to false
{
Serial.println("True");
delay(100);
}
else
{
Serial.println("False");
delay(100);
}
if (strncmp("left", "leftcenter", 4) == 0) // this will evaluate to true
{
Serial.println("True");
delay(100);
}
else
{
Serial.println("False");
delay(100);
}
String stringOne = String("this");
if (stringOne == "this")
{
Serial.println("this will be true");
delay(100);
}
if (stringOne == "that")
{
Serial.println("this will be false");
delay(100);
}
}