I'm trying to enumerate over an array in C, much like pythons enumerate method.
static void enumerate(char *choices[])
{
int i;
int length = sizeof(choices)/sizeof(*choices);
for (i = 0; i < length; i++)
{
printf("[%d] %s\n", i, choices[i]);
}
}
How I'd expect this to work is, create an array (or list): char *test[] = {"test", "testing};
then pass that array (or list) to the function: enumerate(test);
and the expected output should be:
[0] test
[1] testing
However when I try this, the output I'm getting is just the first item in the array:
[0] test
What am I doing wrong to where this will not work as I'd expect it to?