int B[2][3];int *p = B; // why this is wrong?int (*p)[3] = B; // why this is correct?
Here Both are correct, depends on what you really need.
#include<stdio.h> int main(){ int B[2][3] = {{14,16,18},{19,29,39}}; int *p = B; // why this is wrong? int (*q)[3] = B; // why this is correct? printf("%d %d\n",p[0],p[5]);// here p is pointing to single element printf("%d \n",q[1][0]);// here q is pointing to whole 1 D array }
64.3k questions
77.9k answers
244k comments
80.0k users