📄 newrecord.c
字号:
void newRecord(FILE * fPtr)
{
char y_n;
struct examination ex3;
int acctNum;
bingo1:
printf("Enter new 试题编号(1~100): ?");
scanf("%d",&acctNum);
fseek(fPtr,(acctNum - 1)*sizeof(struct examination),SEEK_SET);
fread(&ex3,sizeof(struct examination),1,fPtr);
if(ex3.acctNum != 3)
{
printf("编号 # %d already contains information.\n",acctNum);
}
else
{
printf("Enter 试题内容(<100 bytes) :?");
scanf("%s",ex3.content);
printf("Enter 试题答案(<10 bytes) :?");
scanf("%s",ex3.answer);
printf("Enter 试题题型(1~3) :?");
scanf("%d",&ex3.type);
while(ex3.type!=1||ex3.type!=2||ex3.type!=3)
{
printf("输入有误,请重输");
scanf("%d",&ex3.type);
}
printf("Enter 试题知识点(1~15) :?");
scanf("%d",ex3.knowledge);
while(ex3.knowledge<1||ex3.knowledge>15)
{
printf("输入有误,请重输");
scanf("%d",&ex3.knowledge);
}
ex3.acctNum = acctNum;
fseek(fPtr,(ex3.acctNum - 1)*sizeof(struct examination),SEEK_SET);
fwrite(&ex3,sizeof(struct examination),1,fPtr);
printf("添加成功!");
}
printf("是否继续添加?(Y/N)");
y_n = getch();
printf("%c",y_n);
if(y_n == 'y')
goto bingo1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -