错误:“total”的参数1的不兼容类型 [英] error: incompatible type for argument 1 of `total'
本文介绍了错误:“total”的参数1的不兼容类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#include <stdio.h>
float total(float, int);
typedef struct BOOK
{
int serial;
char title[30];
char author[30];
float price[30];
int quantity;
}BOOK;
int main()
{
BOOK a[2];
int x;
float sum;
for(x=0;x<2;x++)
{
printf("Please Enter Your Book Serial Number :\n");
scanf("%d", &a[x].serial);
printf("Please Enter Your Book Title :\n");
scanf("%s", &a[x].title);
printf("Please Enter Your Book Author :\n");
scanf("%s", &a[x].author);
printf("Please Enter Your Book Price :\n");
scanf("%f", &a[x].price);
printf("Please Enter Book Quantity :\n");
scanf("%d", &a[x].quantity);
sum = total(a[x].price, a[x].quantity);
}
printf("Your Total Is : %.2f\n",sum);
return 0;
}
float total(float z,int y)
{
return z*y;
}
推荐答案
总计$>的第一个参数的类型c $ c>函数是
float
,而BOOK :: price
的类型是float *
。
The type of the first parameter of the
total
function isfloat
, while the type ofBOOK::price
isfloat*
.
我认为您错误地将价格定义为数组。
更改
I think you mistakenly defined price as an array.
Change
引用:
浮动价格[30 ];
float price[30];
到
to
float price;
这篇关于错误:“total”的参数1的不兼容类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文