error: ISO C++ forbids comparison between pointer and integer

Hello,

I am new to Arduino programming, and I am attempting to read a P1-telegram from a smart meter. It has been done before, but I like to know the code, and have the fun of writing it.

The message is:
error: ISO C++ forbids comparison between pointer and integer

My code (for readability I have removed a lot of lines that did not create the error, I have checked this smaller code and it still gives me the error):

#include <AltSoftSerial.h>

AltSoftSerial altSerial;

char c;
String inputString;
int interpret = 0;

void setup() {
  Serial.begin(9600);
  altSerial.begin(9600);
  Serial.print("void setup run");
}

void loop() {
  while (altSerial.available() > 0) {
    c = altSerial.read();
    c &= ~(1 << 7);
    char inChar = (char)c;
    Serial.print(inChar);
    inputString += c;
    
    if((char)c == "!"){
      interpret = 1;
    }
  }
  if (interpret == 1) {
  //  do something
  interpret = 0;
  }
}

When I check the code it highlights the line "if((char)c == "!"){"
I have also tried the following variations of that line:
if(c == "!"){
if(inChar == "!"){

I've searched Google and this forum, but all of the topics I've found had problems with a single "=" insead of a double "==".

The point of this check is that a P1-message is always closed by an "!", and I want to defer the second part of the code to when the message is completely loaded in. If I don't have a check on this, it will execute that piece of code every time it adds a character to inputString.

Could somebody point me in the right direction, because I've run out of ideas on this one.

if((char)c == "!"){

Should be

if(c == '!'){

(It really isn't necessary to cast a char to a char)

That did the trick!

The problem was that I used double quotes instead of single quotes. Is there a page where I can see what the exact difference is between a single or double quote in this language?

Any C/C++ tutorial should make things clear

Okay, will look into that!

I have a long way to go I realize :slight_smile: