You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
781 B
40 lines
781 B
#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;
|
|
}
|