how to store characters?

Hi…
How to store characters which displayed on LCD? I use my own keypad from pin 22-50 to input the characters
I want to compare it with another code
Please Help…

my keypad code

#include <LiquidCrystal.h>

const int buttonPinA = 22; 
const int buttonPinB = 23; 
const int buttonPinC = 24;
const int buttonPinD = 25; 
const int buttonPinE = 26;
const int buttonPinG = 27;
const int buttonPinH = 28;
const int buttonPinI = 29; 
const int buttonPinJ = 30; 
const int buttonPinK = 31;
const int buttonPinL = 32; 
const int buttonPinM = 33; 
const int buttonPinN = 34;
const int buttonPinO = 35; 
const int buttonPinP = 36; 
const int buttonPinR = 37;
const int buttonPinS = 38; 
const int buttonPinT = 39; 
const int buttonPinU = 40;

const int buttonPin1 = 41;
const int buttonPin2 = 42;
const int buttonPin3 = 43;
const int buttonPin4 = 44;
const int buttonPin5 = 45;
const int buttonPin6 = 46;
const int buttonPin7 = 47;
const int buttonPin8 = 48; 
const int buttonPin9 = 49;
const int buttonPin0 = 50;

int buttonStateA = 0;       
int buttonStateB = 0;
int buttonStateC = 0;
int buttonStateD = 0;       
int buttonStateE = 0;
int buttonStateG = 0;
int buttonStateH = 0;       
int buttonStateI = 0;
int buttonStateJ = 0;
int buttonStateK = 0;       
int buttonStateL = 0;
int buttonStateM = 0;
int buttonStateN = 0;       
int buttonStateO = 0;
int buttonStateP = 0;
int buttonStateR = 0;       
int buttonStateS = 0;
int buttonStateT = 0;
int buttonStateU = 0;       

int buttonState1 = 0;
int buttonState2 = 0;
int buttonState3 = 0;       
int buttonState4 = 0;
int buttonState5 = 0;
int buttonState6 = 0;
int buttonState7 = 0;
int buttonState8 = 0;       
int buttonState9 = 0;
int buttonState0 = 0;

LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

void setup() {

  pinMode(buttonPin1, INPUT);
  pinMode(buttonPin2, INPUT);
  pinMode(buttonPin3, INPUT);
  lcd.begin(16, 2);
  lcd.cursor();
}

void loop() {

  buttonState1 = digitalRead(buttonPin1);
  buttonState2 = digitalRead(buttonPin2);
  buttonState3 = digitalRead(buttonPin3);
  buttonState4 = digitalRead(buttonPin4);
  buttonState5 = digitalRead(buttonPin5);
  buttonState6 = digitalRead(buttonPin6);
  buttonState7 = digitalRead(buttonPin7);
  buttonState8 = digitalRead(buttonPin8);
  buttonState9 = digitalRead(buttonPin9);
  buttonState0 = digitalRead(buttonPin0);
  
  buttonStateA = digitalRead(buttonPinA);
  buttonStateB = digitalRead(buttonPinB);
  buttonStateC = digitalRead(buttonPinC);
  buttonStateD = digitalRead(buttonPinD);
  buttonStateE = digitalRead(buttonPinE);
  buttonStateG = digitalRead(buttonPinG);
  buttonStateH = digitalRead(buttonPinH);
  buttonStateI = digitalRead(buttonPinI);
  buttonStateJ = digitalRead(buttonPinJ);
  buttonStateK = digitalRead(buttonPinK);
  buttonStateL = digitalRead(buttonPinL);
  buttonStateM = digitalRead(buttonPinM);
  buttonStateN = digitalRead(buttonPinN);
  buttonStateO = digitalRead(buttonPinO);
  buttonStateP = digitalRead(buttonPinP);
  buttonStateR = digitalRead(buttonPinR);
  buttonStateS = digitalRead(buttonPinS);
  buttonStateT = digitalRead(buttonPinT);
  buttonStateU = digitalRead(buttonPinU);
    
  
  if (buttonStateA == HIGH) 
  {    // print the character
 lcd.print("A");
 delay(5000);
  }

 if (buttonStateB == HIGH) 
  {    // print the character
 lcd.print("B");
 delay(5000);
  }
 
  if (buttonStateC == HIGH) 
  {    // print the character
 lcd.print("C");
 delay(5000);
  }
  
  if (buttonStateD == HIGH) 
  {    // print the character
 lcd.print("D");
 delay(5000);
  }

 if (buttonStateE == HIGH) 
  {    // print the character
 lcd.print("E");
 delay(5000);
  }
 
 if (buttonStateG == HIGH) 
  {    // print the character
 lcd.print("G");
 delay(5000);
  }

 if (buttonStateH == HIGH) 
  {    // print the character
 lcd.print("H");
 delay(5000);
  }
 
  if (buttonStateI == HIGH) 
  {    // print the character
 lcd.print("I");
 delay(5000);
  }
  
  if (buttonStateJ == HIGH) 
  {    // print the character
 lcd.print("J");
 delay(5000);
  }

 if (buttonStateK == HIGH) 
  {    // print the character
 lcd.print("K");
 delay(5000);
  }

  if (buttonStateL == HIGH) 
  {    // print the character
 lcd.print("L");
 delay(5000);
  }

 if (buttonStateM == HIGH) 
  {    // print the character
 lcd.print("M");
 delay(5000);
  }
 
  if (buttonStateN == HIGH) 
  {    // print the character
 lcd.print("N");
 delay(5000);
  }
  
  if (buttonStateO == HIGH) 
  {    // print the character
 lcd.print("O");
 delay(5000);
  }

 if (buttonStateP == HIGH) 
  {    // print the character
 lcd.print("P");
 delay(5000);
  }
 
 if (buttonStateR == HIGH) 
  {    // print the character
 lcd.print("R");
 delay(5000);
  }

 if (buttonStateS == HIGH) 
  {    // print the character
 lcd.print("S");
 delay(5000);
  }
 
 if (buttonStateT == HIGH) 
  {    // print the character
 lcd.print("T");
 delay(5000);
  }
  
 if (buttonStateU == HIGH) 
  {    // print the character
 lcd.print("U");
 delay(5000);
  }
 
   if (buttonState1 == HIGH) 
  {    // print the character
 lcd.print("1");
 delay(5000);
  }

 if (buttonState2 == HIGH) 
  {    // print the character
 lcd.print("2");
 delay(5000);
  }
 
  if (buttonState3 == HIGH) 
  {    // print the character
 lcd.print("3");
 delay(5000);
  }
  
  if (buttonState4 == HIGH) 
  {    // print the character
 lcd.print("4");
 delay(5000);
  }

 if (buttonState5 == HIGH) 
  {    // print the character
 lcd.print("5");
 delay(5000);
  }
 
 if (buttonState6 == HIGH) 
  {    // print the character
 lcd.print("6");
 delay(5000);
  }

 if (buttonState7 == HIGH) 
  {    // print the character
 lcd.print("7");
 delay(5000);
  }
 
  if (buttonState8 == HIGH) 
  {    // print the character
 lcd.print("8");
 delay(5000);
  }
  
  if (buttonState9 == HIGH) 
  {    // print the character
 lcd.print("9");
 delay(5000);
  }
   
  if (buttonState9 == HIGH) 
  {    // print the character
 lcd.print("9");
 delay(5000);
  }
}

That is one of the most ridiculous programs I have ever seen.

But anyway, what do you mean by "store" a character ? Where do you want to store it, and how long do you want to store it for ?

The simple answer would be, in a variable or array of type char.

Learn how to use arrays and you will only need to type about 10% as much code (or even less) with the additional benefits of less opportunity for typos and greater ease in modifying code.

In principle you just need to add the line I have in bold if you want to save the character.

if (buttonStateC == HIGH)
{ // print the character
lcd.print("C");
inChar = 'C';
}

But you really really need to use arrays.

...R