I want to call a function that puts up a menu with something like this :
Mode_Menu("Item 1", "Item A1c", "Item Fred", ..... "Item xxx")
where n
could be any reasonable number and each item can be of random length.
I've tried the following (ignore the numbers in Offer_Mode
- that's just the Y
coordinate on the LCD)
void Mode_Menu(char *m1, ...)
{
va_list argp;
va_start(argp, *m1);
Offer_Mode(2, m1++);
Offer_Mode(33, m1++);
Offer_Mode(64, *m1++;
Offer_Mode(97, *m1++);
Offer_Mode(130, *m1++);
}
But what I get is
Item 1
tem 1
em 1
m 1
1
i.e. the pointer is moving along the first element and never even sees the second element in the function call.
I've tried all the incantations I can think of to step along to the following elements using things like *m1[]
or m1[2]
in the function definition and in va_start
but everything I try throws up an errors.
Can somebody point me to the correct way to do this please?
(and I have searched extensively first so please don't mark as duplicate. There's lot of examples using integers but none that I can find using char arrays).