Indeed ItC... i think i was mixed up with the notation show at the bottom of this fragment:
Code:
char *a[2];
char *b[2];
char **all[2] = {a, b};
a[0]= (char *)malloc(20);
a[1]= (char *)malloc(20);
b[0]= (char *)malloc(20);
b[1]= (char *)malloc(20);
*(a + 0) = "AEI";
*(a + 1) = "OUY";
printf("string: %s\n", a[0]);
printf("string: %s\n", a[1]);
printf("char: %c\n", *(*(a + 0) + 0));
printf("char: %c\n", *(*(a + 0) + 1));
printf("char: %c\n", *(*(a + 0) + 2));
*(*(all + 1) + 0) = "DOG";
*(*(all + 1) + 1) = "CAT";
printf("string: %s\n", b[0]);
printf("string: %s\n", b[1]);
printf("char: %c\n", *(*(*(all + 1) + 0) + 0));
printf("char: %c\n", *(*(*(all + 1) + 0) + 1));
printf("char: %c\n", *(*(*(all + 1) + 0) + 2));
printf("char: %c\n", *(*(*(all + 1) + 1) + 0));
printf("char: %c\n", *(*(*(all + 1) + 1) + 1));
printf("char: %c\n", *(*(*(all + 1) + 1) + 2));
Which Outputs:
string: AEI
string: OUY
char: A
char: E
char: I
string: DOG
string: CAT
char: D
char: O
char: G
char: C
char: A
char: T
Many hours later I have "completed" the main program with one annoying warning about passing non const data to const parameters...
Code:
int main()
{
void test(const char * const *[]);
char *a[MAX];
char *b[MAX];
char *c[MAX;
char **all[MAXMEMBER] = {a, b, c};
test(all);
}
void test(const char * const *total[])
{
; //modify individual characters or the string as a whole is an error... but still a warning
}
Which gives me a "passing argument 1 of ‘test’ from incompatible pointer type" in eclipse and a similar warning in gcc. I am thinking some kind of cast is appropriate here.