首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

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

2012-09-24 
结构体下接收函数后输出的问题,在线求解#includestdio.hstruct Employee{int idNumchar name[20]doubl

结构体下接收函数后输出的问题,在线求解
#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); 

热点排行