title: C Pointer Casting
body: <pre><code>#include &lt;stdio.h&gt;
  int main(void)
   {
    char *cp;
    short *sp;
    int *ip;
    short x[6];
    int i, y;
    y = 0x0102;
    for (i = 0; i &lt; 6; i++) 
    {
      x[i] = y;
      y = y + 0x1010;
    }
    cp = (char*) x;
    printf("1) *cp = %x\n", *cp);
    sp = x;
    printf("2) *sp = %x\n", *sp);
    printf("3) cp[3] = %x\n", cp[3]);
    ip = (int*) x;
    ip = ip + 1;
    printf("A) *ip = %x\n", *ip);
    printf("B) cp[6] = %x\n", cp[6]);
    sp = sp + 5;
    printf("C) *sp = %x\n", *sp);
    *x = *cp + 2;
    printf("D) cp[1] = %x\n", cp[1]);
    return 0;
  }
  </code></pre>
  
  <p>I do not understand how the short array is typecasted to a char, and what happens when the typecast happens. Could someone kindly help me out with this !!</p>