title: Why does pointer typecasting to float doesn't work?
body: <p>Hi everyone I am learning C and i am trying to print values of different data types using a single char pointer. I am able to print almost every data type but having problems to print float. Can anyone explain why this is an issue ?! And how can i print the exact float value using a single pointer. Sorry for the noob question, if it turns out to be one. I understand the alignment problem. But really need a solution to this. </p>
  
  <p>UPDATE 1--> Sorry for the stupid typecasting. Now consider the update code.      </p>
  
  <p>UPDATE 2 --> Thank you everyone for answering. Like i said,i am learning C, sorry for the syntax errors. I am not from CS background.But thank you so much again.  </p>
  
  <pre><code>    #include &lt;stdio.h&gt;
  
  int main()
  {
      long int a = 10;
      char ch = 'a';
      float b = 16.89;
      unsigned int c = 20;
      short int d = 30;
      char *p;
      p = &amp;a;
      printf("Value of a: %d\n", *p);
      p = &amp;ch;    
      printf("Value of ch: %c\n", *p);
      p = &amp;b;                                     
      printf("Value of b(float): %f\n", *p);
      printf("Value of b(decimal): %d\n", (int) *((float*)p));    
      p = &amp;c;
      printf("Value of c: %u\n", *p);
      p = &amp;d;
      printf("Value of d: %i\n", *p);
      return 0;
  }
  
  The output of the above program is :-
  Value of a: 10
  Value of ch: a
  Value of b(float): 0.000000
  Value of b(decimal): 16
  Value of c: 20
  Value of d: 30
  </code></pre>