I have two arrays
int x[]={1,2,3,4};
int y[]={5,6,7};
I like to create two dimensional array. assign x and y. Can I do something like this
int x[]={1,2,3,4};
int y[]={5,6,7};
int *k=x;
int *l=y;
int **m={k,l};
printf("%d\n",m[0][0]);
but at printf when 1 is get accessed throws segFault
What I am doing wrong
int **m={k,l};. Your code should work if you change that line toint *m[2]={k,l};, makingman array and not a pointer; this could (and should, for robustness) be changed toint *m[]={k,l};. The latter deduces the (still fixed at compile time) array size from the number of items between the braces, so you don't have to change a number if in the future you add another array element. But it is still a true array with two elements and not a pointer likeint **mis.