📄 updaterecord.c
字号:
void updateRecord(FILE * fPtr)
{
char y_n;
int acctNum;
struct examination ex2;
printf("显示所有试题:");
printf("any key to show ..");
getch();
rewind(fPtr);
while(!feof(fPtr))
{
fread(&ex2,sizeof(struct examination),1,fPtr);
if(ex2.acctNum == 0)
printf("%d%-3s%-3s%-3d%-3d \n",ex1.acctNum,ex1.content,ex1.answer,ex1.type,ex1.knowledge);
}
loop1:
printf("Enter 编号 to update(1~100): ?");
scanf("%d",&acctNum);
while(acctNum<1||acctNum>100)
{
printf("输入有误请重输: ?");
scanf("%d",&acctNum);
}
fseek(fPtr,(acctNum - 1)*sizeof(struct examination),SEEK_SET);
fread(&ex2,sizeof(struct examination),1,fPtr);
if(ex2.acctNum == 0)
{
printf("编号 %d has no information.\n",acctNum);
}
else
{
printf("%d%-3s%-3s%-3d%-3d \n",ex1.acctNum,ex1.content,ex1.answer,ex1.type,ex1.knowledge);
printf("Enter new 试题内容(<100 bytes):\n?");
scanf("%s",ex2.content);
printf("Enter new 答案(<10bytes):\n?");
scanf("%s",ex2.answer);
fseek(fPtr,(acctNum - 1)*sizeof(struct examination),SEEK_SET);
fwrite(&ex2,sizeof(struct examination),1,fPtr);
printf("update 成功!\n");
}
printf("是否愿意继续 to update ?");
y_n = getch();
printf("%c",y_n);
if(y_n == 'y') goto loop1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -