1. ## 2d arrays

I wrote this code.
Code:
```int a[1][2]={{10,1}};int *b[1]={{10,1}};
int main(){
printf("%d",**a);   //prints 10
printf("%d",**b);    //gives error
printf("%d",*b);    //gives 10
}```
Why does **b give error? And why does *b give 10? Shoudn't it give a pointer?

2. > Why does **b give error?

> And why does *b give 10?
Because that's what you stored in the array to begin with.
If you want to pretend that 10 is a pointer, then later on pretend that the pointer is an int, you get back to where you started.

> Shoudn't it give a pointer?
Perhaps you should use a decent compiler that will give you warnings about incompatible types in assignment.

3. I am a beginner in c and I'm not understanding what you said.

I declared
Code:
`int *b[]`
which is an array of pointers to int. So when I assign it
Code:
`{{10,1}}`
, shouldn't *b give a pointer to where first element of the first array in b, ie 10, is stored, not 10 itself? Also, adding 1 to *b refers to first element of second array in b(not present here). How do I refer to the second element of first array in b, ie 1 ?

4. Nope. Incidentally, what you're doing is initialising, not assigning.

The initialisers of an array of pointers initialise the pointers with the supplied values. The additional braces don't change that so
Code:
`    int *b[1]={{10,1}};`
is equivalent to
Code:
`    int *b[1]={10,1};`
which has the same net effect (including warnings from your compiler, if used with appropriate non-default warning levels) as
Code:
```    int *b[2];
b[0] = 10;
b[1] = 1;```
The type of shorthand you expect (initialisers that look like arrays leading to pointers being initialised to the first elements in those arrays) isn't what you get.

5. How could it have the same effect? b should have 1 element but you wrote 2.

Let's say I wrote

Code:
`int *b[]={{10,1},{5,3}};`
then b[0] should be 10, b[1] is 1 and so on. But b[1] is 5 and that's it.

Also if I try

Code:
`char *b[]={"ab","cde"};`
it works as I wrote before. Isn't "ab" just a character array?

I am a bit confused.

6. Perhaps you would be less confused if you stored integers in an integer array, and printed them as integers.

Instead of all this hooky 'ints-as-pointers' rubbish which won't even compile on a modern compiler.