title: C : Error : "format ‘%f’ expects argument of type ‘double’"
body: <p>I'm getting back to C and have just been doing some small exercises, and I stumbled at this one and can't get the reason why this is happening??</p>
  
  <p>The program takes a 9 word long code example "011112222". The first number is the code for the operation (0 for +, 1 for -, 2 for *, 3 for /) the next 4 numbers are the first number and other 4 is the other number so for "011112222" the result should be 1111+2222.</p>
  
  <p>But I get a constant error of : 
  In function ‘main’:</p>
  
  <pre><code>zadatak.c:54:14: warning: format ‘%f’ expects argument of type ‘double’, but argument 2 has type ‘float *’ [-Wformat=]
       printf("%f", result);
  </code></pre>
  
  <p>It would be great if someone can shed a light to this problem, I would be grateful.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
      #include &lt;unistd.h&gt;
      #include &lt;stdlib.h&gt;
      #include &lt;string.h&gt;
  
      float* Calculate(char* buffer)
      {
          int number1, number2;
  
          char *firstPart = (char *)malloc(strlen(buffer));
          char *secondPart = (char *)malloc(strlen(buffer));
  
          strncpy(firstPart, buffer+1, 4);
          strncpy(secondPart, buffer+5, 8);
  
          number1 = atoi(firstPart);
          number2 = atoi(secondPart);
  
          float *result;
  
          if( buffer[0] == '0')
          {
              *result = (float)number1 + (float)number2;
          }
          else if(buffer[0] == '1')
          {
              *result = (float)number1 - (float)number2;
          }
          else if(buffer[0] == '2')
          {
              *result = (float)number1 * (float)number2;
          }
          else if(buffer[0] == '3')
          {
              *result = (float)number1 / (float)number2;
          }
  
          return result;
      }
  
      int main()
      {
          char buffer[20];
          printf("Insert code word: ");
          scanf("%s", buffer);
  
          float *result = Calculate(buffer);
          printf("%f", result);
  
          return 1;
      }
  </code></pre>