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;
}
展开
 我来答
C_C_猫
2013-11-05 · TA获得超过122个赞
知道小有建树答主
回答量:160
采纳率:0%
帮助的人:139万
展开全部
#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;
}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式