
C语言一道程序案例,求帮忙看下哪里出错了。
#include<stdio.h>#include<process.h>#defineSIZE9typedefstructtax_st{longleft;longrigh...
#include <stdio.h>
#include <process.h>
#define SIZE 9
typedef struct tax_st
{
long left;
long right;
int tax;
long deduct;
} TAX_LIST;
void acceptdata(TAX_LIST tax_list[])
{
int i;
for (i=0; i<SIZE; i++)
{
printf("Please enter data:");
scanf("%ld",&tax_list[i].left);
scanf("%ld",&tax_list[i].right);
scanf("%d",&tax_list[i].tax);
scanf("%ld",&tax_list[i].deduct);
}
}
int main()
{
FILE *fp;
TAX_LIST tax_list [SIZE];
if(((fp=fopen("D:\\各种\\C语言\\vc\\书上的例子\\TAX.din","wb")) == NULL)
{
printf("\ncannot open file\n");
exit(1);
}
acceptdata(tax_list);
if ((fwrite(tax_list,sizeof(TAX_LIST),SIZE,fp)!=SIZE)
printf("file write error\n");
fclose (fp);
return 0;
} 展开
#include <process.h>
#define SIZE 9
typedef struct tax_st
{
long left;
long right;
int tax;
long deduct;
} TAX_LIST;
void acceptdata(TAX_LIST tax_list[])
{
int i;
for (i=0; i<SIZE; i++)
{
printf("Please enter data:");
scanf("%ld",&tax_list[i].left);
scanf("%ld",&tax_list[i].right);
scanf("%d",&tax_list[i].tax);
scanf("%ld",&tax_list[i].deduct);
}
}
int main()
{
FILE *fp;
TAX_LIST tax_list [SIZE];
if(((fp=fopen("D:\\各种\\C语言\\vc\\书上的例子\\TAX.din","wb")) == NULL)
{
printf("\ncannot open file\n");
exit(1);
}
acceptdata(tax_list);
if ((fwrite(tax_list,sizeof(TAX_LIST),SIZE,fp)!=SIZE)
printf("file write error\n");
fclose (fp);
return 0;
} 展开
1个回答
展开全部
#include <stdio.h>
#include <process.h>
#define SIZE 9
typedef struct tax_st
{
long left;
long right;
int tax;
long deduct;
} TAX_LIST;
void acceptdata(TAX_LIST tax_list[])
{
int i;
for (i=0; i<SIZE; i++)
{
printf("Please enter data:");
scanf("%ld",&tax_list[i].left);
scanf("%ld",&tax_list[i].right);
scanf("%d",&tax_list[i].tax);
scanf("%ld",&tax_list[i].deduct);
}
}
int main()
{
FILE *fp;
TAX_LIST tax_list [SIZE];
if((fp=fopen("D:\\各种\\C语言\\vc\\书上的例子\\TAX.din","wb")) == NULL) //
{
printf("\ncannot open file\n");
exit(1);
}
acceptdata(tax_list);
if (fwrite(tax_list,sizeof(TAX_LIST),SIZE,fp)!=SIZE) //
printf("file write error\n");
fclose (fp);
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询