N
No_One
Ran across the following in some source code while learning ncurses.
#include <curses.h>
#include <menu.h>
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
char *choices[] = {
"Choice 1",
"Choice 2",
"Choice 3",
"Choice 4",
"Exit",
(char *)NULL,
};
n_choices = ARRAY_SIZE(choices);
Now my question is, the define is dividing the size of the array choices by
the size of the first eleemnt of that array to get the number of elements in
the array.
Right ?
If so then wouldn't this only work if all the elements were the same size???
ken
#include <curses.h>
#include <menu.h>
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
char *choices[] = {
"Choice 1",
"Choice 2",
"Choice 3",
"Choice 4",
"Exit",
(char *)NULL,
};
n_choices = ARRAY_SIZE(choices);
Now my question is, the define is dividing the size of the array choices by
the size of the first eleemnt of that array to get the number of elements in
the array.
Right ?
If so then wouldn't this only work if all the elements were the same size???
ken