a function-definition is not allowed here before '{' token

written in c

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);

}

void loop() {
  //variable for each button
  int button1 = digitalRead(2);
  int button2 = digitalRead(3);
  int button3 = digitalRead(4);
  int button4 = digitalRead(5);
  int button5 = digitalRead(6);
  int button6 = digitalRead(7);
  int button7 = digitalRead(8);
  int button8 = digitalRead(9);
  int button9 = digitalRead(10);
  
  // currently pressed password array
    int pressed[8];
    pressed[0] = button1;
    pressed[1] = button2;
    pressed[2] = button3;
    pressed[3] = button4;
    pressed[4] = button5;
    pressed[5] = button6;
    pressed[6] = button7;
    pressed[7] = button8;
  //correct password
  int truePass[8];
  //set password function
    int setPass() {
     int SetPressed[8];
    truePass[0] = button1;
    truePass[1] = button2;
    truePass[2] = button3;
    truePass[3] = button4;
    truePass[4] = button5;
    truePass[5] = button6;
    truePass[6] = button7;
    truePass[7] = button8;
  }
}

error:
exit status 1
a function-definition is not allowed here before ‘{’ token

I am not sure what is the problem I tried solving it and failed,
any assistance is welcome.

passwordProject.ino (1.27 KB)

You're creating the function int setPass() inside loop().

void loop() {
  ....
  ....
  //set password function
  int setPass() {
    int SetPressed[8];
    truePass[0] = button1;
    truePass[1] = button2;
    truePass[2] = button3;
    truePass[3] = button4;
    truePass[4] = button5;
    truePass[5] = button6;
    truePass[6] = button7;
    truePass[7] = button8;
  }
} // loop() ends here

Unlike some other programming languages, you can't define a function within another function in C or C++.