注册 登录
编程论坛 C语言论坛

输入数据后没按任意键退出的提示

domore 发布于 2019-08-07 07:21, 1789 次点击
为什么不出现“按任意键退出的提示”了
PS:书上照抄的代码,本以为是标识符class的问题,改成其他的名字也没用

#include<stdio.h>
#include<stdlib.h>
struct employee
    {
    char num[6];
    char name[10];
    char sex[2];
    int age;
    char addr[20];
    int salary;
    char health[8];
    char class[10];
    }em[4];

int main()
    {
    FILE *fp;
    int i;
    printf("input NO.,nam,sex,age,addr,salary,health,class:\n");
    for(i=0;i<4;i++)
    scanf("%s %s %s %d %s %d %s %s",
    em[i].num,em[i].name,em[i].sex,&em[i].age,em[i].addr,&em[i].salary,em[i].health,em[i].class);
    if((fp=fopen("employee","w"))==NULL)
        {
        printf("can not open file.");
        exit(0);
        }
    for(i=0;i<4;i++)
        if(fwrite(&em[i],sizeof(struct employee),1,fp)!=1)
            printf("file write error!!!\n");
    fclose(fp);
    return 0;
    }
   
3 回复
#2
吹水佬2019-08-07 10:20
哪一句是“按任意键退出的提示”
#3
自学的数学2019-08-07 10:45
应该是:“按任意键继续的提示”的意思吧。
#4
zbjzbj2019-08-07 10:57
楼主问的都是三年级的问题,还是先读一年级的课本吧。
1