I want to create a structure like this:
struct commands
{
int cmd;
char descr[25];
};
commands cmds[] =
{
{16, "Hammond Organ"},
{17, "Percussive Organ"},
{18, "Rock Organ"},
{ 0, "" } // end of list marker
};
The compiler doesn't protest, but in a simulator the values of cmds[i].descr are all zeros.
And the line
Serial.write(cmds[1].descr);
prints nothing.
Please recommend how to rewrite the code.
Thanks.
EDIT
Thanks for your answer. It helped me a lot.
There is something wrong with the simulator (Simulator for Arduino - version 1.11E Designed by Virtronics). In the meantime I received the Mega 2560 board and the code works well with the board.
avr-nm -Cn path_to_the_elf_fileto see the memory address wherecmdsis stored, thenavr-objdump -s -j .data path_to_the_elf_fileto see its contents. Does it look as expected?