# Thread: Explain the difference between b and *b?

1. ## Explain the difference between b and *b?

Code:
```#include<stdio.h>
void main()
{
int a[]={1,2,3,4,5};
int (*b)[5];
b=a;
printf("%u %u %u\n",b,*b,*b[0]);
printf("%u %u %d",sizeof(b),sizeof(*b),*b[0]);
}
o/p:
1000 1000 1
4 20 1```

2. b is of type "pointer to an array of five int". *b is of type "array of five int".

3. If *b is of type "array of five int" ,then Is any extra array getting created for this purpose?

4. No array is created -- when you set a pointer, the idea is that you are pointing it at something.

5. You may want to take a look at Prelude's tutorial on pointers. It should answer most of your questions.

6. If no extra array is created, then how can we say *b is of type "array of five int"...? Is that the property it is holding??

7. That's why it is of type "array of five int". As in it is the declaration of what kind of object it is. Read the link I posted for you.

8. Originally Posted by ackr1201
If no extra array is created, then how can we say *b is of type "array of five int"...? Is that the property it is holding??
Remember, b is of type "pointer to array of 5 ints", so *b is of type "array of 5 ints". Just like with int *p, p is of type "pointer to int" and *p is of type "int". You're dereferencing the pointer when you put that * in front of it, so the resulting type is whatever is pointed to.

EDIT: And remember, you set b to point to a, so dereferencing it doesn't create an array, but it does yield the array pointed to by b

9. Originally Posted by ackr1201
If no extra array is created, then how can we say *b is of type "array of five int"...? Is that the property it is holding??
The type of a variable (b, in this case) is a property of the variable. The value is another property of that variable.

The two do not automatically go together (except in some special circumstances that are not particularly relevant here). That means creating a pointer does not magically create a companion pointee.