I have serial data I want to compare a specific byte to the letter “G”.
LPtype is a byte that was read from the serial port.
if (LPtype == "G")
{
doThis();
}
I get the following error:
C++ forbids comparison between pointer and integer
What would be the proper way of comparing the incoming bye to the letter G? (or any other letter for that matter)
Singular quotes. But LP usually prefixes pointer types, in which case you should dereference it
But if you’re sure LPtype is indeed a byte value, then
should work. The thing is that
"G"has typeconst char[2], and is not an integer type, whereas'G'has typecharand is integer type