The following is correct. I'll explain below.
typedef struct TEST {
int total;
char *myarray[];
} Test;
int StackOveflowTest(void)
{
int index;
Test *mystruct = malloc(sizeof(Test)+10*sizeof(char *));
for (index=0; index<10; index++)
mystruct->myarray[index] = strdup("hello world");
mystruct->total = index;
for (index=0; index<10; index++)
printf("%s\n", mystruct->myarray[index]);
return 0;
}
Actually, you declare an "array of pointers" myarray, however that array has zero elements. This "trick" is used to have the ability that at the end of the struct you have an array of variable size when malloc'ing the array:
Test *mystruct = malloc(sizeof(Test)+10*sizeof(char *));
This allocates the size of the struct and adds room for 10 array elements.
Since you did not allocate this flexible part of the struct, you wrote into "nothing" and are lucky the program did not abort (or it did, which is why there was no output).
P.s.: don't forget to free the memory when you are done:
for (index=0; index<10; index++)
free(mystruct->myarray[index]);
free(mystruct);