【问题标题】:Error called object 'calculateTaxes' is not a function or function pointer称为对象“calculateTaxes”的错误不是函数或函数指针
【发布时间】:2019-11-03 07:48:17
【问题描述】:

在我的程序中,我必须向用户询问当月的总销售额,然后向用户询问县税率(6%)和州销售税(6%),然后根据以下公式计算总销售税他们输入了什么。我还必须使用指针。

我不断收到以下错误:[Error] called object 'calculateTaxes' is not a function or function pointer

我似乎无法弄清楚。这是我到目前为止的代码

#include <stdio.h>

int inputTaxData(int* totalSales);
float calculateTaxes;
int main()


{
int* totalSales;
inputTaxData(&totalSales);
calculateTaxes();
float c;
float s;
float t;

    return 0;
}


int inputTaxData(int* totalSales)
{
printf("What is your total sales for the month?");
scanf("%d", totalSales);
}


float calculateTaxes(float c, float s, float t)
{
float c = 1.06;
float s = 1.06;
float t = c + s;
printf ("Your total state and county sales tax is %f", totalSales);
}

【问题讨论】:

  • 查看您的个人资料,您似乎错过了接受最有帮助的答案的概念。 stackoverflow.com/help/someone-answers 它不需要你接受一个,但如果你不能接受一个,你可能想解释一下缺少什么。

标签: c function pointers tax


【解决方案1】:

您声明float calculateTaxes;,即作为浮点变量。
然后你尝试把它作为一个函数来调用。

calculateTaxes();

这是编译器试图告诉你的。
您可能想为后来定义的函数提供一个原型。

float calculateTaxes(float c, float s, float t);

【讨论】:

  • 您的代码还有其他问题,这可能会导致它无法按照您的预期执行。不过,我相信您会自己找到它们,或者提出相应的单独问题。
  • 我知道我遗漏了一些单独的问题,我会尽快找到这些问题
猜你喜欢
  • 2012-06-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多