Problem writing/reading string in EEPROM

Hello guys!
I want to store in EEPROM my Wi-Fi’s ssid and password, but I have difficulties doing that.
Please, can you have a look over my code, to tell me why can’t read string back? Thank you!!!

#include<EEPROM.h>
char ssid[]="my_wifi"; 
char pass[30];

void setup()
 {
  Serial.begin(9600);
  setSSID();
 }


void loop(){;}


void setSSID()
  {
   byte l=strlen(ssid);
   EEPROM.write(1,l);
   byte x=0;
   int i=24;

   while(i<i+l)
      {
       EEPROM.write(i,ssid[x++]);
       delay(4);
       i++;
      }

   char readBack[l+1];
   byte y=0;
   int j=24;
   while(j<j+l)
      {
       readBack[y++]=EEPROM.read(j);
       j++;
      }
   
   readBack[y]='\0';
   Serial.print("\n This is the Network's SSID:  ");
   Serial.print(readBack);
  }

If you're using an ESP8266 it will store the last connected credentials by itself, no need to try and store it yourself.

Yes, I will use ESP8266,but anyway,I want to write this function in case that I will use also Arduino
Wi-Fi Shield, and for general purposes of using EEPROM,other than storing network configuration.

while(i<i+l)

Are you sure?

At this very moment I am only sure that I need any help I can get. :slight_smile:

i know that somothing is wrong somewhere.
Any way, I've started from from this premise: the "ssid" and "pass" arrays will be initiated from
Serial Monitor and I don't know the length of them.

Do look up the EEPROM documentation - especially the EEPROM.put() and EEPROM.get() functions. Those make storage easy.