Not quite.
Check the range of array indices generated by the for loop.
(Most people index C arrays from zero)
Please remember to use code tags when posting code
You could certainly do what you suggest but all that would happen at the end of the for loop is that the variable k would have the value read from EEPROM address 9
You need to read up on arrays and do something like
char k[10]; //declare an array of chars with 10 levels numbered 0 to 9
for (int byte i = 0; i < 10; i++)
{
k[i] = EEPROM.read(i);
}
If what you are reading is to be used as a C style string then the array will need to have 11 levels and you will need to add the trailing zero to level 10 to make it into a string.
From your earlier post. Note my added/revised comments
char k[200]; //declare an array of chars with 200 levels numbered 0 to 199
for (int byte i = 1; i < 201; i++) //i will have a value of 200 during the final iteration of the for loop
{
k[i] = EEPROM.read(i); //**THERE IS NO LEVEL 200 IN THE ARRAY**
}
Be VERY careful with array index variables as it is all to easy to overwrite memory that is not in the array, as above.
As previously pointed out, array levels start at 0, not 1
char k[200]; /*declare an array of chars with 200 levels numbered 0 to 199*/
for (int byte i = 0; i < 200; i++) /* i will have a value of 199 during the final iteration of the for loop*/
{
k[i] = EEPROM.read(i); //**THERE IS NO LEVEL 200 IN THE ARRAY**
}
char k[200]; /*declare an array of chars with 200 levels numbered 0 to 199*/
for (int byte i = 0; i < 200; i++) /* i will have a value of 199 during the final iteration of the for loop*/
{
l[i] = EEPROM.read(i); //**THERE IS NO ELEMENT 200 IN THE ARRAY**
}
In fact, I don't know if the void setup can support loops.