EEPROM

i've been trying to put an array in the eeprom and read it out( its part of a bigger code which would be too long to post) untill now i havent succeed. i cant find where my problem is? maybe the data type? i have no experience with the eeprom memory so i'm still figuring it all out

for(int i = 0; i < 4; i++){
   safetyscode1[i]= ingavecode1[i];
   EEPROM.write(50+i,safetyscode1[i]);
}
for(int i = 0; i < 4; i++){
   EEPROM.get(50+i,safetyscode1[i]);
}
Serial.print(safetyscode1[i]);

  safetyscode1[i]= ingavecode1[i];Why ?

Serial.print(safetyscode1[i]);What do you expect this to print bearing in mind that it is outside of the for loop ?

How are the two arrays declared ?

int ingavecode1[5];
      int safetyscode1[5];

the safetyscode1[i]= ingavecode1[i];
part is because the users who are going to use the lockers can insert their own code. "ingavecode" is the insertedcode and safetscode is the code that will be used later to chek when they want to open their locker.

for(int i = 0; i < 4; i++){
   EEPROM.get(50+i,safetyscode1[i]);
Serial.print(safetyscode1[i]);
}

thanks for noticing it, not solving my problem tho

So the arrays are ints (2 byes each value) but you are doing
EEPROM.write(50+i,safetyscode1[i]);Which writes a byte to the EEPROM.

Perhaps you should look at EEPROM.put() to go with EEPROM.get()

Why are the arrays ints ? What is the maximum value that will be stored at each level ?

also ints are 2 bytes. each eeprom address is one byte.
try int8_t for integers from -127 to 127 or uint8_t for integers from 0 to 255.

i fixed it by doing this, idk why it works tbh, dut it does... coding right ?

for(int i = 0; i < 4; i++){
   safetyscode1[i]= ingavecode1[i];
   EEPROM.write(50+(i*4),safetyscode1[i]);
}

i fixed it by doing this, idk why it works tbh, dut it does... coding right ?

Stop pi$$ing about and use EEPROM.put() or make the arrays byte instead of int.

You did not answer the question about the values that will be held in the arrays