I already created several projects with different Arduinos, but now struggle with a strange behavior writing to a multidimensional string array:
I only write to one specific cell of my array ([1][0]), but the value is set to two cells ([1][0] and[0][2]).
I could not find any similar topic when searching. The issue is also present after downloading with different PCs and also to different Arduinos (Nano as well as Mega).
The most obvious problem is that in the TestArrayCall() function you change the value of a local variable, rTable, and do nothing with it. Changing the local array will have no effect on the array used when calling the function.
In loop() I print the first two rows to serial (two cells are changed instead of one).
When I also print the values of the array within the call I can see the exact same behavior.
Here is the adapted code with Serial.println in TestArrayCall():
Start
loop: Array before
| |
| |
Call: Array before
| |
| |
Call: Array after
| | Test [1][0]
Test [1][0] | |
loop: Array after
| | Test [1][0]
Test [1][0] | |
=> In loop() as well as in TestArrayCall(), two cells are modified instead of one.
Why is the value set to two different cells? How is it possible to only write to one cell?
Thank you in advance for any hints!