user29266: I'm trying to read compare data from EEPROM (Arduino UNO). Reading is working fine but comparing it using the '==' operator is not working as expected.
//string 'True' is already stored in EEPROM

int addr = 0;
char value = EEPROM.read(addr);

Serial.println(value);// this line successfully prints the letter 'T'

// but this function is not working
if (value == "T") {
  Serial.println("foo");
}


user23841: There is a HUGE difference between "string" and 'c' 'h' 'a' 'r'.
You are comparing address of string "T" with the numerical value of character 'T'.
The expression: if (value == 'T') will be much better.

29266: <p>I'm trying to read compare data from EEPROM (Arduino UNO). Reading is working fine but comparing it using the '==' operator is not working as expected.</p>

<pre><code>//string 'True' is already stored in EEPROM

int addr = 0;
char value = EEPROM.read(addr);

Serial.println(value);// this line successfully prints the letter 'T'

// but this function is not working
if (value == "T") {
  Serial.println("foo");
}
</code></pre>
 23841: <p>There is a HUGE difference between <code>"string"</code> and <code>'c' 'h' 'a' 'r'</code>.</p>

<p>You are comparing address of string <code>"T"</code> with the numerical value of character <code>'T'</code>.</p>

<p>The expression: <code>if (value == 'T')</code> will be much better.</p>
