I'm going to use an Arduino to play a melody, the melody is split into 11 parts which stored in an array called notes
Here's the code:
String notes[0][]={"do", "re", "mi", "fa"};
String notes[1][]={"so", "rest", "mi", "do", "rest", "so", "rest", "fa", "re", "rest",
"fa", "rest", "re", "ti", "rest", "fa", "rest", "mi", "do", "rest"};
String notes[2][]={"rest", "si,", "do", "fa", "mi", "so", "do", "rest", "mi"
"fa", "mi", "fa", "mi", "fa", "mi", "do", "re"};
String notes[3][]={"la,", "la", "so", "fa", "mi", "fa", "so", "do", "do",
"rest", "mi", "fa", "mi", "do", "fa", "mi", "do", "la", "so", "rest"};
String notes[4][]={"rest", "so,", "so,", "fa", "mi", "re", "mi", "do"};
String notes[5][]={"la", "ti", "so", "fa", "so", "fa",
"fa", "mi", "re", "mi", "re", "do", "ti,", "do", "ti,", "la,", "so,"};
String notes[6][]={"rest", "do", "ti,", "do", "so,", "rest"};
String notes[7][]={"do", "ti,", "do", "mi", "rest"};
String notes[8][]={"fa", "mi", "re", "do", "fa", "mi", "re", "do", "do", "re", "re", "do`", "re`"};
String notes[9][]={"rest", "do", "ti,", "do", "so", "fa", "fa", "fa", "fa", "fa", "mi", "re", "mi",
"rest", "re", "mi", "fa", "mi", "mi", "mi", "re", "do", "mi", "rest"};
String notes[10][]={"la,", "ti,", "do", "re", "la,", "la,", "ti,", "do", "re", "do", "so"};
When I tried to compile it, it returns an error message saying that
declaration of 'notes' as multidimensional array must have bounds for all dimensions except the first
so what should I do if I want to keep the contents in the array unchanged?
String notes[][] = { {..}, {..}, {..} }
.enum
, make the arrays be arrays of 1-byte elements containing the enum values, and then when you want to get a string, have a lookup table where the enum value translates to a string