title: Interesting problem on pointers..Please help
body: <pre><code>#include&lt;iostream&gt;
  #include&lt;conio.h&gt;
  
  using namespace std;
  int main()
  {
             int x = 65;
             int *ptr = &amp;x;
             char * a= (char *)ptr;
             cout&lt;&lt;(int)*(a);
             getch();return 0;
  }           
  </code></pre>
  
  <p>Sixeof(ptr) and Sizeof(a) display 4<br>
  Sizeof(int) displays 4 and sizeof(char) displays 1<br>
  So 65 is stored in 4 bytes ie<br>
  00000000 00000000 00000000 01000001 and address of first bytes is stored in ptr</p>
  
  <p>In the above code I have type casted the int* to char* in a motive to print the value stored in x(type int) first byte.</p>
  
  <p>So after typecasting "a" stores the first byte address ie contained in ptr as well
  Now on displaying (int)*a shouldn it consider only first byte for showing the value..?? 
  but the output is 65 instead of 0(first byte value)..Where am I going wrong..?</p>
  
  <p>what I have learnt is</p>
  
  <pre><code>char * ptr1;
  ptr1++;  //Ptr1 goes to the next byte..*ptr1 will display only 1 byte value
  
  int  * ptr2;
  ptr1++;  //Ptr2 goes to the next 4 byte..*ptr2 will display value conmtain in 4 bytes
  </code></pre>
  
  <p>PS - I am working on Dev-C++</p>