How to make all button presses and their values, write to one variable in the matrix of buttons

Description

I want to record all clicks in one variable, and then compare them with another variable …
now I can do it through an array, and then if I write down the clicks in different cells

What MCU/Processor/Board and compiler are you using?

PC simulator

What LVGL version are you using?

v6

What do you want to achieve?

I want to record all the presses in one variable, and then compare them with another variable

What have you tried so far?

my sample with array

      if(event == LV_EVENT_CLICKED) {
               const char * txt = lv_btnm_get_active_btn_text(obj);
                printf("%s was pressed\n", txt);
                if ( x <=4 ) {
        		       sesurity_pass[x] = txt;
        		       x++;
        	   }
        }


The code block(s) should be formatted like:
```c
/*You code here*/

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

Your approach seems correct. I can’t imagine a simpler way.