Hi guys
Lets look at an example:
This code creates an array of pointers to char, and makes the pointers point to the character arrays "hi" and "all", respectively. Now, my question is regarding the following code:Code:char *str[]={"hi", "all"};
As you may know by now, the above code is completely wrong. My question is: Why is it wrong? Because in the first example with strings, the array of pointers to char point to character-arrays. In the second example, the pointers to integer point to integer-arrays.Code:int intarr[2][2]={{1,2} , {3,4}};
int *intptr[]=intarr;
Why is it that in the integer-case, I must specify that the pointers point to arrays of length 2 (i.e. int (*intptr)[2] is correct), while I do not have to do that in the string-case?
Best,
Niles.