2 dimensional array of chars.


if have 1 dimensional array of chars

char command[20]; 

which contains set of chars 0 terminated.

so

command[0]="h"
command[1]="e"
command[2]="l"
command[3]="l"
command[4]="o"
command[5]=(char)0

i can refer command serial.println(command); works , prints hello

now problem:

if have 2 dimensional array of chars

char commands[20][5]; 

which contains set of chars 0 terminated.

so

commands[0][0]="h"
commands[1][0]="e"
commands[2][0]="l"
commands[3][0]="l"
commands[4][0]="o"
commands[5][0]=(char)0
commands[0][1]="w"
commands[1][1]="o"
commands[2][1]="r"
commands[3][1]="l"
commands[4][1]="d"
commands[5][1]=(char)0

how can refer group in that

serial.println(commands[][0]);  can't work
and serial.println(commands[0]);  can't work because wouldn't know element talking about......


[font=verdana]is there way ????
[/font]

unless you've got peculiar requirements, i'd you've got array indices wrong way round.


commands[0][0]="h"
commands[0][1]="e"
commands[0][2]="l"
commands[0][3]="l"
commands[0][4]="o"


Arduino Forum > Using Arduino > Programming Questions > 2 dimensional array of chars.


arduino

Comments

Popular posts from this blog

Thread: PKI Client 5.00 install (for eToken Pro)

ATmega2560-Arduino Pin Mapping

Crossfader Arduino Tutorial