Hello,
First, if you want to have a two dimensional array of strings then you actually need a char ***, since you would have an array of arrays to arrays of characters (say that 10 times fast).
Second, you need to assign memory for each array of pointers that you use. So with your example, you'd need to allocate memory before doing the assignment.
So
char **p;
*p = "Hello World"
doesn't work, but
char **p;
p = malloc(sizeof(char*)*3);
*p = "Hello World";
or
char *p[3];
p = "Hello World";
does.
When doing this with a two dimensional array of strings your best bet would probably be to assign some or all of the memory statically (assuming that you will always have 3 lines with 3 strings in each line).
Here's a little example that asks the user to enter stri
ngs and then fills in a table and prints it out:
#include
int main()
{
char *p[3][3];
char buffer[100];
int i,j;
printf("Enter 9 strings:\n");
for(i = 0; i < 3; i++)
for(j = 0; j < 3; j++)
{
scanf("%s", buffer);
p[i][j] = malloc(sizeof(char)*(strlen(buffer)+1));
strcpy(p[i][j], buffer);
}
fflush(stdin);
printf("\nTable Display:\n");
for(i = 0; i < 3; i++)
{
for(j = 0; j < 3; j++)
printf("%s\t", p[i][j]);
printf("\n");
}
printf("Hit q to quit.\n");
getchar();
return 0;
}
Note that this is all standard C programming, there isn't anything CVI specific here. You might want to find a C programming book.
Regards,
Ryan K.
NI