J
Jeremy Targett
Hello, I'm trying to initialise a two-dimensional array of characters, 12 by
60, with each entry maximum 6 characters wide. (It's a fix I'm making to an
old program which I learned just enough C for at the time, and since then
I've become rusty, and can't seem to figure this out.)
this (as you know) won't work:
char lily_pitch[12][60][7];
lily_pitch[0]={"c,", "des,", "d,", "ees,", "fes,", "f,", "ges,", "g,",
"aes,", "beses,", "bes,", "ces", "c", "des", "d", "ees", "fes", "f", "ges",
"g", "aes", "beses", "bes", "ces'", "c'", "des'", "d'", "ees'", "fes'", "f'",
"ges'", "g'", "aes'", "beses'", "bes'", "ces''", "c''", "des''", "d''",
"ees''", "fes''", "f''", "ges''", "g''", "aes''", "beses''", "bes''",
"ces'''", "c'''", "des'''", "d'''", "ees'''", "fes'''", "f'''", "ges'''",
"g'''", "aes'''", "beses'''", "bes'''", "ces''''"};
(then similar initialisations for lily_pitch[1] through [11])
What's the proper syntax, please? Should I be initialising the whole 12 by 60
array at once, in the declaration?
Also, will I have to pad out each entry so it's 6 characters?
Or maybe there's a completely different, better way - I just need to be able
to do something equivalent to
printf("%s",lily_pitch[j]);
during the program. If there's a better way than using arrays like this, I'd
appreciate any tips.
Many thanks,
JT
p.s. those entries in the array look funny don't they - if you're curious,
they're musical pitches formatted to be read by lilypond, a music typesetter.
60, with each entry maximum 6 characters wide. (It's a fix I'm making to an
old program which I learned just enough C for at the time, and since then
I've become rusty, and can't seem to figure this out.)
this (as you know) won't work:
char lily_pitch[12][60][7];
lily_pitch[0]={"c,", "des,", "d,", "ees,", "fes,", "f,", "ges,", "g,",
"aes,", "beses,", "bes,", "ces", "c", "des", "d", "ees", "fes", "f", "ges",
"g", "aes", "beses", "bes", "ces'", "c'", "des'", "d'", "ees'", "fes'", "f'",
"ges'", "g'", "aes'", "beses'", "bes'", "ces''", "c''", "des''", "d''",
"ees''", "fes''", "f''", "ges''", "g''", "aes''", "beses''", "bes''",
"ces'''", "c'''", "des'''", "d'''", "ees'''", "fes'''", "f'''", "ges'''",
"g'''", "aes'''", "beses'''", "bes'''", "ces''''"};
(then similar initialisations for lily_pitch[1] through [11])
What's the proper syntax, please? Should I be initialising the whole 12 by 60
array at once, in the declaration?
Also, will I have to pad out each entry so it's 6 characters?
Or maybe there's a completely different, better way - I just need to be able
to do something equivalent to
printf("%s",lily_pitch[j]);
during the program. If there's a better way than using arrays like this, I'd
appreciate any tips.
Many thanks,
JT
p.s. those entries in the array look funny don't they - if you're curious,
they're musical pitches formatted to be read by lilypond, a music typesetter.