Logical problem involving arrays

Dear all, with a keypad and LCD interfaced to the arduino mega I have managed to display what the user presses on the LCD. My problem is here; if for example the user writes 0043 - this value is saved into an array;

How can I save this value as a whole in a variable ??

This is the code used:

 //Display refernce no on lcd
  for(int x =0; x<4;x++)      //loop to save amount entered (4 digit no)
    {
    
      do
      {
        reference_no = customKeypad.getKey();        //get amount from keypad
        Serial.println(reference_no);                //serial print for testing
      
      
        if(reference_no == 0)                        //amount is always 0 when waiting for key to get pressed
         {
           flag = true;         
         }
       
         else if((reference_no == '0')||(reference_no == '1') ||(reference_no == '2')||(reference_no == '3')
                 || (reference_no == '4') || (reference_no == '5') || (reference_no == '6') || (reference_no == '7')
                 || (reference_no == '8') || (reference_no == '9'))                        //for pressing any digit no
         {
           reference_no = reference_no - 48;        //since from keypad, the characters are displayed as ASCII
           lcd.setCursor(x,0);          //move cursor to desplay nos pressed
           lcd.print(reference_no);
           tempreferarray[x] = reference_no;         //saving in array
           reference_no = reference_no - reference_no;  //so that reference_no is equal to the value before when loop is begun again
           flag = false; 
         }
       }
      while(flag == true);
    }
    lcd.setCursor(4,0);        
    lcd.print("ref no");
    delay(2000);
    
    Serial.println(tempreferarray[3]);  //display last no in array

tnx

Convert the number to decimal, and store it in an "int".

if((reference_no == '0')||(reference_no == '1') ||(reference_no == '2')||(reference_no == '3')
                 || (reference_no == '4') || (reference_no == '5') || (reference_no == '6') || (reference_no == '7')
                 || (reference_no == '8') || (reference_no == '9'))

aka

if((reference_no >= '0') && (reference_no <= '9'))

That still leaves the number stored in an array, since I need to input a 4 digit no.

I want the 4 digit no to be saved as a integer as a whole.

What this program does is store the 4 digit no in an array[4].
Now I need to store the whole values in the array to an integer

Tnx

Still not sure what you're saying - an array is a variable.
Are you saying you need a two dimensional array?

If you store it as an int, you can infer any leading zeroes, and any trailing or infix ones will be explicit.

No.

The user enters a 4 digit number.
The digits are saved in an array[4]

For example before the usre enters the nos pressed by the keypad, the array is like this :
arr[] = ,_ ,, , _
when he presses 1, the array is now like this :
arr[] = 1 ,
, , _
pressing 2,...:
arr[] = 1,2,
,

pressing 3
arr[] = 1,2,3,_
pressing 4:
arr[] = 1,2,3,4

Now I want the values stored in the array; i.e. arr[0], arr[1],...arr[3] to be stored in a single integer.
Meaning i will have an integer having an amount of 1234.

That is my problem
Tnx

Multiply the thousands digit by one thousand, add in the hundreds digit multiplied by one hundred...

Damn lol
Tnx