读书人

结构体上接收函数后输出的有关问题在

发布时间: 2012-09-24 13:49:41 作者: rapoo

结构体下接收函数后输出的问题,在线求解
#include<stdio.h>
struct Employee
{
int idNum;
char name[20];
double payRate;
double hours;
};
printf("please input the idNumber\n");
scanf("%d",&idNum);
printf("please input the name\n");
scanf("%c",&name[]);
printf("please input the payRate\n");
scanf("%d",&payRate);
printf("please input the hours in workday\n");
scanf("%d",&hours);
double calcNet(struct Employee);

int main()
{
struct Employee emp={idNum,payRate,hours};
double netpay;

netpay=calcNet(emp);
printf("the net pay of employee %d is $%6.2f\n",emp.idNum,netpay);

return 0;
}

double calcNet(struct Employee temp)
{
return(temp.payRate*temp.hours);
}

[解决办法]

C/C++ code
printf("please input the idNumber\n");scanf("%d",&idNum);printf("please input the name\n");scanf("%c",&name[]);printf("please input the payRate\n");scanf("%d",&payRate);printf("please input the hours in workday\n");scanf("%d",&hours);double calcNet(struct Employee); 

读书人网 >C语言

热点推荐