parent
2cc395efca
commit
c9ece6227e
@ -0,0 +1,39 @@
|
||||
#include<stdio.h>
|
||||
#include<malloc.h>
|
||||
#include<windows.h>
|
||||
#include <stdlib.h>
|
||||
#define TRUE 1
|
||||
#define ERROR 0
|
||||
#define MAX 30
|
||||
typedef int Status;
|
||||
typedef struct{
|
||||
char option1[30],option2[30],option3[30],option4[30],subject[150];
|
||||
char result;
|
||||
}TestNode;
|
||||
TestNode Testquestions[MAX];
|
||||
|
||||
Status SaveNode(int N) //把结构体数组保存到文件“单项选择题考试题库”中
|
||||
{
|
||||
int i;
|
||||
FILE *fp;
|
||||
if((fp=fopen("单项选择题考试题库","wb"))==NULL)
|
||||
return ERROR;
|
||||
for(i=0;i<N;i++)
|
||||
fwrite(&Testquestions[i],sizeof(TestNode),1,fp);
|
||||
fclose(fp);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Status ReadNode(int N) //从文件中读出结构体数组的内容
|
||||
{
|
||||
FILE *fp;
|
||||
int i=0;
|
||||
if((fp=fopen("单项选择题考试题库","rb"))==NULL)
|
||||
return ERROR;
|
||||
while(!feof(fp))
|
||||
{
|
||||
fread(&Testquestions[i],sizeof(TestNode),1,fp);
|
||||
i++;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
Loading…
Reference in new issue