Hi dear Forum Members,
first of all a very warm thank you for all the information put together here in the forum. I could solve a lot of issues programming my arduinos reading your input.
Despite reading back and forth I was not able to get a clear image about the use of multidimensional char arrays. It is easy to initialize it and to fill it while initializing. But then I am lost.
First of all: it is clear to initialize it as:
char arr[2][2] = {{'a','b'},{'c','d'}};
But if I have already a char and I would like to copy it to arr, how to do that?
- option:
char arr[4][4];
char text[] = {'abc‘};
arr[0][] = text;
- option:
char arr[4][4];
char text[] = {'abc‘};
for (int i = 0; i < strlen(text); i++){
arr[0][i] = text[i];
}
Neither of these options is working.
Also when I like to read out with Serial, the following is quite easy:
char arr[] = {'thisisanarray‘};
Serial.print(arr);
But how to use this in multidimensional arrays?
This is not working:
char arr[2][2] = {{'a','b'},{'c','d'}};
Serial.print(arr[0][]);
This isn't working too:
char arr[2][2] = {{'a','b'},{'c','d'}};
for (int i = 0; i < strlen(arr[0]; i++){
Serial.print(arr[0][i];
}
I hope you got my issue where I am lost in the details.
Would be fantastic if someone could leave me a message how to do it right.
Thank you all
kduino