title: Can int pointer be casted to char *?
body: <p>The below program tests for Little/Big endian on intel processor. Actually little endian is correct output. First I am casting <code>int</code> to <code>char*</code> and accessing its value without initialization to <code>int *</code>.I am not understanding second part of output. Here <code>int</code> pointer is casted to <code>char *</code>. So why is not <code>int</code> pointer not changed its alignment to <code>char *</code>?</p>
  
  <pre><code>00000000 00000000 00000011 01111111 = 895
  0        0         3       127
  
  int main() {
      int num = 895;
      if(*(char *)&amp;num == 127)
      {
          printf("\nLittle-Endian\n");
      }
      else
      {
          printf("Big-Endian\n");
      }
  
      int *p = (char *)&amp;num ;
      if(*p == 127)
      {
          printf("\nLittle-Endian\n");
      }
      else
      {
          printf("Big-Endian\n");
      }
      printf("%d\n",*p);
  }
  
  o/p
  
  Little-Endian
  Big-Endian
  895
  </code></pre>