Question: I have done type casting with `int` and `char` but not with pointers so I posted this question.

```
#include <stdio.h>
int main() {
    int a[4] = { 1, 2, 6, 4 };
    char *p;
    p = (char *)a;   // what does this statement mean?
    printf("%d\n",*p);
    p = p + 1;        
    printf("%d",*p);  // after incrementing it gives 0 why?
}

```

The first call to `printf` gives the first element of the array. And after `p=p+1` it gives `0`. Why?

Answer: 
```
int a[4] = { 1, 2, 6, 4 };

```

declares a as array. `a` at this point of time stores the address of the first element of the array.

```
char *p;

```

declares p as a `pointer` to `character`

```
p = (char *)a;

```

Now since `p` & `a` both stores addresses. So the address stored at `a` (`address` of first element of the array) is assigned to `p`. The typecasting is done as `p` was declared as `char *`

what it does is that, assuming address stored at `a` is say 100 *and assuming that `int` takes 2 bytes and `char` takes 1 bytes in memory*

```
a+1 would return a+size of int(2) = 102

```

and 

```
p+1 would return p+size of char(1) = 101 

```

and that will explain the output as 

A. two bytes stored at `a` contains the first element of the array.

B. one byte stored at `p` is the character representation of the first byte of integer `1`, which is `0`.

Hope this helps.
a is a pointer to an array of memory. This memory is probably arranged in little endian twos complement format as a contiguous block of 16 bytes.

When you cast it, you basically just said "okay, I know this is a pointer to an array of ints, but now we're going to reinterpret the data as an array of chars". char typically is one byte. So, when you added one to the pointer, you incremented the *place* the pointer pointed to. Because it is a char array, it advanced one *byte* down the array, which is in the middle of the int, which contains 0.

To clarify, *based on what I assume about your computer's architecture*:

> 
> Little endian numbers (the least significant byte comes first):  
> 
>  00000001000000000000000000000000 in binary = 1 in decimal
>  00000010000000000000000000000000 in binary = 2 in decimal
>  00000110000000000000000000000000 in binary = 6 in decimal
>  00000100000000000000000000000000 in binary = 4 in decimal
> 
> 
> 

Your array of ints looks like this:

> 
> 00000001000000000000000000000000000000100000000000000000000000000000011000000000000000000000000000000100000000000000000000000000
> 
> 
> 

The variable "a" points to the first integer, which is 32 bits (i.e., "\*a" is `00000001000000000000000000000000`). If you add one to the variable "a", you increment *the pointer*, so \*(a+1) points to the second int `00000010000000000000000000000000`).

Now, you cast the variable "a" to a "char\*" pointer. So, now, the variable "p" points to the same place, but because it is a char pointer, pointers to the first char, which is 8 bits (i.e., "\*p" is `00000001`, the first byte of your array).

Finally, when you increment "p", you increment the *pointer*. Because "p" is a pointer to chars, it advances one *byte*, so "\*(p+1)" is `00000000`.