Initialize array of strings
c, initialization
Solution
This example program illustrates initialization of an array of C strings.
#include <stdio.h>
const char * array[] = {
"First entry",
"Second entry",
"Third entry",
};
#define n_array (sizeof (array) / sizeof (const char *))
int main ()
{
int i;
for (i = 0; i < n_array; i++) {
printf ("%d: %s\n", i, array[i]);
}
return 0;
}
It prints out the following:
0: First entry
1: Second entry
2: Third entry
Problem
What is the right way to initialize `char**` ? I get coverity error - Uninitialized pointer read (UNINIT) when trying: ``` char **values = NULL; ``` or ``` char **values = { NULL }; ```