title: C Student Assignment, ‘%f’ expects argument of type ‘float *’, but argument 2 has type ‘double *’
body: <p>I'm working on an assignment and I'm getting this warning:</p>
  
  <pre><code>C4_4_44.c:173:2: warning: format ‘%f’ expects argument of type ‘float *’, 
  but argument 2 has type ‘double *’ [-Wformat]
  </code></pre>
  
  <p>The variabled is declared in main as: </p>
  
  <pre><code>double carpetCost;
  </code></pre>
  
  <p>I'm calling the function as: </p>
  
  <pre><code>getData(&amp;length, &amp;width, &amp;discount, &amp;carpetCost);
  </code></pre>
  
  <p>And here's the function:</p>
  
  <pre><code>void getData(int *length, int *width, int *discount, double *carpetCost)
  
  {
  
      // get length and width of room, discount % and carpetCost as input
  
      printf("Length of room (feet)? ");
  
      scanf("%d", length);
  
      printf("Width of room (feet)? ");
  
      scanf("%d", width);
  
      printf("Customer discount (percent)? ");
  
      scanf("%d", discount);
  
      printf("Cost per square foot (xxx.xx)? ");
  
      scanf("%f", carpetCost);
  
      return;
  
  } // end getData
  </code></pre>
  
  <p>This is driving me crazy because the book says that you don't use the &amp; in </p>
  
  <pre><code>scanf("%f", carpetCost); 
  </code></pre>
  
  <p>when accessing it from a function where you passed it be reference. </p>
  
  <p>Any ideas what I'm doing wrong here?</p>