I have an array of char pointers in C with a size of 10.
I am trying to loop through and print each string out. Not all of the elements are populated and I believe this is causing me an error. How do I check if an element is populated.
This is what I have tried. When I run my code I find that the first element is populated and the value is printed but then I get an error.
char *errors[10];
ret = doMessages(&h, errors);
for (i = 0; i < 10; i++)
{
if(errors[i] != NULL)
{
printf("%s", errors[i]);
}
}
errorsis not initialised so the elements can be any value, specifically may not be NULL. Change to: