I'm working on an assignment and I'm getting this warning:
C4_4_44.c:173:2: warning: format ‘%f’ expects argument of type ‘float *’, but argument 2 has type ‘double *’ [-Wformat] The variabled is declared in main as:
double carpetCost; I'm calling the function as:
getData(&length, &width, &discount, &carpetCost); And here's the function:
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 This is driving me crazy because the book says that you don't use the & in
scanf("%f", carpetCost); when accessing it from a function where you passed it be reference.
Any ideas what I'm doing wrong here?
scanfreference.printf("%f", double_value);scanf("%f", &float_value).