weird outputs

my code is giving me a changing output when the output should stay the same, the code should be comparing buttons and passTrue and writing 1 to serial if it’s the same and 0 if it’s not, I didn’t manage to find a pattern.
here’s my code:

int i;
int passTrue[9];
int buttons[9];


void setup() {
  Serial.begin(9600);
  pinMode(2, INPUT_PULLUP);
  pinMode(3, INPUT_PULLUP);
  pinMode(4, INPUT_PULLUP);
  pinMode(5, INPUT_PULLUP);
  pinMode(6, INPUT_PULLUP);
  pinMode(7, INPUT_PULLUP);
  pinMode(8, INPUT_PULLUP);
  pinMode(9, INPUT_PULLUP);
  pinMode(10,INPUT_PULLUP);
  pinMode(13, OUTPUT);

Test();
}

int * SetButtons() {
  for (int i = 0; i<=8; ++i) {
    buttons[i] = digitalRead(i);
 }
  return buttons;
}     


int * SetPass() {
  i = 0;
  for (i = 1; i<=8; ++i) {
     if(buttons[i] == LOW) {
      passTrue[i] = buttons[i];
     }
  }
return passTrue;
}
  
  void CheckPass() {
    for(i=0; 0<=8; ++i) {
      if(passTrue[i] != buttons[i]) {
        Serial.println("0");
      } else {
        Serial.println("1");
      }
    }
  }

void Test() {
  for(i=0; i<=8; ++i) {
   buttons[i] = 0;
   passTrue[i] = 1;
  }
}

  void loop() {
CheckPass();
  }

here is a link to my tinkercad circuit of the project:

int * SetButtons() {
  for (int i = 0; i<=8; ++i) {
    buttons[i] = digitalRead(i);
 }

You are reading pins 0 through 8, not 2 through 10.

Maybe?

buttons[i] = digitalRead(i+2);

I fixed the issue you pointed out but the problem presists, if you go to the link you can see the updated code, I changed setButtons to:

int * SetButtons() {
int  k=2;
  for (int i = 0; i<=8; ++i) { 
    buttons[i] = digitalRead(k);
    k++;
 }
  return buttons;
}

Why are you returning a global?

You think this might be an issue?

  void CheckPass() {
    for(i=0; 0<=8; ++i) {

Declare a global array called pins and put your pin numbers in that so that you can iterate through them more easily. This will remove a lot of the confusion from your code.

const int pinCount = 10;
int pins[pinCount] = {2,3,4,5,6,7,8,9,10,13};

//now you can iterate through them like this:
for(int i=0; i<pinCount; i++){
  pinMode(pins[i], OUTPUT);
}

The stuff you are saying are all good and well but they don’t have any relation to the problem, the stuff in the setup already happend, so only the stuff in the loop should matter, and the only thing there is the checkPass, so I don’t have any idea how your answers relate to my question.
that said I will probably change my code accordingly soon.
possibly I will be able to run the program on an arduino tommorow, maybe it’s a tinkercad issue.

I pointed out the problem in reply #4 and tested it in Tinkercad and it works for me.

Replace:

  void CheckPass() {
    for(i=0; 0<=8; ++i) {

with:

  void CheckPass() {
    for(i=0; i<=8; ++i) {