Just trying to really understand the arrays and pointers to C and the differences between them, and I am having problems with 2d arrays.
For a normal 1D array, this is what I found out:
char arr[] = "String constant";
creates an array of characters, and the variable arrwill always represent the memory created when it was initialized.
char *arr = "String constant";
creates a pointer to char, which currently points to the first index of the char array "String constant". A pointer may point elsewhere later.
char *point_arr[] = {
"one", "two","three", "four"
};
creates an array of pointers, which then point to the char arrays of "one", "two", etc.
My question
If we can use both:
char *arr = "constant";
and
char arr[] = "constant";
then why can't i use:
char **pointer_arr = {
"one", "two", "three", "four"
};
instead
char *pointer_arr[] = {
"one", "two", "three", "four"
};
char **, , , " ". char**, , calloc, char *arr = "blah";. , , :
char **arr_pointer;
char *arr_pointer[];
.