assignment from incompatible pointer type 不知道怎么解决(103,和110行的警告)
/*二、随机文件的读写操作1、已知职工信息包含:职工号、姓名、基本工资、津贴、水电费和实发工资,请从键盘输入10人的信息保存在 wage.dat文件中,并将职工信息依次显示在屏幕上。
2、打开wage.dat文件,输出职工号为偶数的职工信息;
3、打开wage.dat文件,按实发工资从低到高排序,并将排序后的职工信息写到文件 wagesort.dat中,并显示排序后的职工信息。
struct employee{ int number ; char name[10]; double jbgz; double jintie; doube sdfyong; double wage; }employer[10]; */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 2
struct employee {
int number;
char name[10];
int jbgz;
int jintie;
int sdf;
int wage;
};
int main(void) {
struct employee employer[N];
char str[10];
FILE *fp,*fp2;
int i,j,temp;
long record_len;
record_len = sizeof(struct employee);
printf("请输入10个职工的信息:\n");
printf("职工号、姓名、基本工资、津贴、水电费和实发工资\n");
for(i =0; i < N; i++) {
scanf("%d %s %d %d %d ",&employer[i].number,employer[i].name,&employer[i].jbgz,&employer[i].jintie,&employer[i].sdf);
employer[i].wage = employer[i].jbgz + employer[i].jintie - employer[i].sdf;
}
if((fp = fopen("wage.dat","wb")) == NULL)
printf("File open error!\n");
else {
for(i = 0; i <= N; i++) {
fwrite(&employer[i],record_len,1,fp);
}
fclose(fp);
}
//在屏幕上显示职工信息
if((fp = fopen("wage.dat","rb")) == NULL)
printf("File open error!\n");
else {
printf("%6s%10s%10s%10s%10s%10s\n","职工号","姓名","基本工资","津贴","水电费","实发工资");
for(i =0; i < N; i++) {
fread(&employer[i],record_len,1,fp);
printf("%6d%10s%10d%10d%10d%10d\n",employer[i].number,employer[i].name,employer[i].jbgz,employer[i].jintie,employer[i].sdf,employer[i].wage);
}
fclose(fp);
}
if((fp = fopen("wage.dat","rb")) == NULL)
printf("File open error!\n");
else {
printf("职工号为偶数的职工信息为:\n");
printf("%6s%10s%10s%10s%10s%10s\n","职工号","姓名","基本工资","津贴","水电费","实发工资");
for(i = 0; i < N; i+=2) {
fseek(fp,i*record_len,0);
fread(&employer[i],record_len,1,fp);
printf("%6d%10s%10d%10d%10d%10d\n",employer[i].number,employer[i].name,employer[i].jbgz,employer[i].jintie,employer[i].sdf,employer[i].wage);
}
fclose(fp);
}
if((fp = fopen("wage.dat","rb")) == NULL)
printf("File open error!\n");
else {
for(i = 0; i < N; i++)
fread(&employer[i],record_len,1,fp);
for(i = 0; i < N; i++)
for(j = 0; j < N-1-i; j++) {
if(employer[i].wage > employer[i+1].wage) {
temp = employer[i].number;
employer[i].number = employer[i+1].number;
employer[i+1].number = temp;
strcpy(str,employer[i].name);
strcpy(employer[i].name,employer[i+1].name);
strcpy(employer[i+1].name,str);
temp = employer[i].jbgz;
employer[i].jbgz = employer[i+1].jbgz;
employer[i+1].jbgz = temp;
temp = employer[i].jintie;
employer[i].jintie = employer[i+1].jintie;
employer[i+1].jintie = temp;
temp = employer[i].sdf;
employer[i].sdf = employer[i+1].sdf;
employer[i+1].sdf = temp;
temp = employer[i].wage;
employer[i].wage = employer[i+1].wage;
employer[i+1].wage = temp;
}
}
if((fp2 = ("wagesort.dat","wb")) == NULL) 此行有警告
printf("File open error!");
else
for(i = 0; i < N; i++)
fwrite(&employer[i],record_len,1,fp2);
fclose(fp2);
//在屏幕上显示排序后的职工信息
if((fp2 = ("wagesort.dat","rb")) == NULL) 此行有警告
printf("File open error!");
else {
printf("%6s%10s%10s%10s%10s%10s\n","职工号","姓名","基本工资","津贴","水电费","实发工资");
for(i =0; i < N; i++) {
fread(&employer[i],record_len,1,fp);
printf("%6d%10s%10d%10d%10d%10d\n",employer[i].number,employer[i].name,employer[i].jbgz,employer[i].jintie,employer[i].sdf,employer[i].wage);
}
}
fclose(fp2);
}
return 0;
}
可以运行,但会中途停止,求大神解答