If statement not working

This loop requires to enter any value and save it as exitcode by pressing '#'. Then i delcared exitcodeaa to be 11. So if I enter 11 on the kepad and confirm by '#' based on the if loop I must get a "goodbye" displayed on my LCD else "incorrect Code". But I always get "incorrect code"... To confirm that my entered code 'exitcode' is as i entered it on the key I apply it on my serial monitor. Why why why?

void exitkeypadentry()
{

lcd.setCursor(0,0);
lcd.print("Enter Exit Code");

char key = keypad.getKey();

if (key)
{
if (key == '*')
{
memset(entryStr, 0, sizeof(entryStr));
i=0;
key=0;
Serial.println("");
Serial.println("Canceled");
}

else if (key != '#')
{

entryStr*= key;*

  • i++;*

  • Serial.print(key);*

  • }*

  • else*

  • {*

  • Serial.println("");*

  • i=0;*

  • key=0;*

  • String exitcode = entryStr;*

  • memset(entryStr, 0, sizeof(entryStr));*

  • Serial.println("Checking Code...");*

  • Serial.println(exitcode);*

  • int exitcodeaa= 11;*

  • if(exitcode == exitcodeaa)*

  • {*

  • lcd.clear();*

  • lcd.setCursor(0,0);*

  • lcd.print("GoodBye!");*

  • delay(3000);*

  • lcd.clear();*

  • }*

  • else*

  • {*

  • lcd.clear();*

  • lcd.setCursor(0,0);*

  • lcd.print("Incorrect Code");*

  • delay(3000);*

  • lcd.clear();*

  • }*

  • }*
    }
    }

And now with code tags, please

It looks like your problem is comparing a String to an int.

sers/john/Documents/Arduino/sketch_apr29a/sketch_apr29a.ino: In function 'void setup()':
/Users/john/Documents/Arduino/sketch_apr29a/sketch_apr29a.ino:11:19: warning: invalid conversion from 'int' to 'const char*' [-fpermissive]
   if (exitcode == exitcodeaa)
                   ^~~~~~~~~~
In file included from /Users/john/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/Arduino.h:232:0,
                 from sketch/sketch_apr29a.ino.cpp:1:
/Users/john/Library/Arduino15/packages/arduino/hardware/avr/1.8.2/cores/arduino/WString.h:143:16: note:   initializing argument 1 of 'unsigned char String::operator==(const char*) const'
  unsigned char operator == (const char *cstr) const {return equals(cstr);}
                ^~~~~~~~

Perhaps "if (exitcode.toInt() == exitcodeaa)" would work.

Thank you Mr.John it worked.