arduino中的动态数组声明

dynamic array declaration in arduino

我正在尝试制作一个密码,当输入正确的密码时可以打开门。但是,在这样做的同时,我遇到了一个问题。我必须将输入的密码存储在动态数组中。我知道有一个制作动态数组的包但是我不知道制作动态数组的代码。我正在发布我到目前为止所做的代码,即只启动键盘。

#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};

byte rowPins[ROWS] = { 8, 7, 6, 9 };
byte colPins[COLS] = { 5, 4, 3, 2 };
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup() {

  // put your setup code here, to run once:
  Serial.begin(9600);

}

void loop() {

  // put your main code here, to run repeatedly:

}
int* dynamicArray;
dynamicArray = new int[arraySize];
if(dynamicArray == nullptr) {
    //if memory could not be assigned
}
//do stuff with your array
delete[] dynamicArray; //delete when not in use anymore