E
Eric
Suppose I have an arbitrarily long array of character pointers that
should be looped through until the end is reached. What is the correct
way to mark the end of the strings to be processed? E.g.:
#include <stdio.h>
int main(int argc, char **argv)
{
char *month[] = {
"January", "February", "March",
"April", "May", "June",
"July", "August", "September",
"October", "November", "December",
0 /* <== should this be 0 or NULL? */
};
int i = 0;
while (month) { /* Is this safe to do in all cases? */
printf("%s\n", name);
i++;
}
return 0;
}
should be looped through until the end is reached. What is the correct
way to mark the end of the strings to be processed? E.g.:
#include <stdio.h>
int main(int argc, char **argv)
{
char *month[] = {
"January", "February", "March",
"April", "May", "June",
"July", "August", "September",
"October", "November", "December",
0 /* <== should this be 0 or NULL? */
};
int i = 0;
while (month) { /* Is this safe to do in all cases? */
printf("%s\n", name);
i++;
}
return 0;
}