> (*str2)[STR_LEN];
Read the comment again - this is a pointer to an array of chars. You need the extra () to get the precedence right, otherwise its just an array of pointers.
Try and see past the array part, and just think about it in terms of a pointer to any multi-byte object like an int or a structure. The pointer still points to the first byte, but in terms of indexing, pointer arithmetic etc, C treats the whole lot as a single indivisible entity.
str1++ would point to the next char in the current string
str2++ would point to the next string (as you would normally expect if it was a pointer to an int or a struct).
Here's a clearer example without the malloc...
Code:
int main ( ) {
char *str1; // pointer to a char array (of any size)
char (*str2)[10]; // pointer to a char[10] array
char string[10] = "hello";
// char bogus[20] = "world";
// str1 = bogus; // this is legal
// str2 = &bogus; // this isn't legal - the array sizes differ
// point to first element
// there is no information in the pointer to tell us how big the
// thing being pointed at is.
str1 = string; // array names are pointers to the first element
str1 = &string[0]; // ie, equivalent to this
// point to the whole array
str2 = &string; // note - no [0]
printf( "str1 points to %s\n", str1 );
printf( "str1 points to %s\n", &str1[0] );
printf( "str2 points to %s\n", *str2 );
printf( "str2 points to %s\n", str2[0] );
return 0;
}
> are you talking about pointers to functions?
Pointers to functions have () instead of [] in the declaration