简体   繁体   English

函数`float calcSize(int, int, int, int)'的参数太少

[英]Too few arguments to function `float calcSize(int, int, int, int)'

It keeps telling me too few arguments to function in my float calcSize() function, even though I'm sending all 4 variables in it.它一直告诉我在我的 float calcSize()函数中运行的参数太少,即使我在其中发送了所有 4 个变量。 My other question is, does my program make sense?我的另一个问题是,我的程序有意义吗?

#include <stdio.h>
#include <conio.h>
#define PAINT 350.00

//Function Prototype
void displayInstructions();
float calcSize(int , int , int , int );
float calcPaint(float);
float calcCost(float, float);
void displayTotals(float, float, float);

int main()
{
    // Variables
    int l , w , d, win ;
    float s;
    float p;
    float cP = 32.00;
    float c ;  

 displayInstructions();
 //Getting variables
    printf("Please enter the number of heights in feet");
     scanf("%d",&l);
    printf("Please enter the number of width");
     scanf("%d",&w);
    printf("Please enter the number of doors");
     scanf("%d",&d);
    printf("Please enter the number of windows");
     scanf("%d",&win);

    calcSize(l , w , d , win);
     calcSize() = s;
    calcPaint(s);
     calcPaint() = p;
    calcCost(p, cP);
      calcCost() = c;              
    displayTotals(s , p , c);       

getch();
return 0;
}

//Display function    
void displayInstructions()
{
     Printf("Welcome to the Green Paint Calculator!");
     Printf("\nEnter the height and width of the room (in feet)");
     Printf("\nand the number of doors and windows."); 
     Printf("This program will then calculate how many cans of paint needed"); 
     Printf("\n(based on 2 coats of paint).It will then calculate the cost"); 
     Printf("\nbased on the charge per gallon entered");       
}
//Calcsize function
float calcSize(int l, int w, int d, int win)
{    
     float area, areaDoors, areaWindows;

     area = (l + w) * 2 * 8.0;
     areaDoors = d * 20;
     areaWindows = win * 15;

     area -= areaDoors + areaWindows;     
     return area;
}

//calcPaint function
float calcPaint(float s)
{
      float galPaint;

      galPaint = s / PAINT * 2;
      return galPaint;
}
//calccost function
float calcCost(float p, float cP)
{
      return p * cP;
}
//Display total function
void displayTotals(float s, float p, flaot c)
{
     printf("\n\nSize of room in square feet: %.2f", s);
     printf("\nNumber of gallons needed: %.2f", p);
     printf("\nTotal cost to paint room: %.2f", c);
}

You program doesn't make any sense.你的程序没有任何意义。 I don't know what are you trying to do with calcSize() = s;我不知道你想用calcSize() = s;做什么calcSize() = s; . . I think it should be like我认为它应该像

s = calcSize(l , w , d , win); 

if you wanna assign the return value of function to s .如果您想将函数的返回值分配给s

its your code that is wrong..... calcSize(l , w , d , win);它的代码是错误的..... calcSize(l , w , d , win); calcSize() = s; calcSize() = s; calcPaint(s); calcPaint(s); calcPaint() = p; calcPaint() = p; calcCost(p, cP); calcCost(p, cP); calcCost() = c; calcCost() = c;
displayTotals(s , p , c); displayTotals(s, p, c);

use as follows...使用如下...

s= calcSize(l , w , d , win);
// calcSize() = s;[this line shows you too-few arguments] and lvalue error
p= calcPaint(s);
 //calcPaint() = p;[this line shows you too-few arguments]and lvalue error
c=calcCost(p, cP);
  //calcCost() = c; [this line shows you too-few arguments]and lvalue error             
displayTotals(s , p , c);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM