K
Keith Thompson
Martin Ambuhl said:Keith said:Martin Ambuhl said:Army1987 wrote:
You don't even need a function.
const char *wdays = { NULL, "Sunday", "Monday" /*etc.*/ }
and you can use wdays. Or even, throw away the NULL and use wdays[i-1].
That's wrong. And the correct declaration
Yes, it needs to be "const char *wdays[]".
And the correct declaration
static char *day[] =
{ "Error", "Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"
It's *a* correct declaration. Once the "[]" is added, I fail to see
why your declaration is more correct.
You yourself have noted that "const char *wdays" is wrong and "const
char *wdays[]" is correct. I fail to see how in the world you can be
obtuse enough not to see that mine is more correct than Army1987's.
A more interesting question is why Army1987 would post such an obvious
error three days after more correct (despite your inconsistent claim
that you can't see why it is) answer had been posted.
Read again. See where I wrote 'Once the "[]" is added, ...'?
Of course Army1987's declaration is incorrect, and yours is more
correct. I was comparing *a corrected version of* Army1987's
declaration to your declaration.