init_examination.c

来自「比较原始的学校出题系统」· C语言 代码 · 共 30 行

C
30 行
字号
#include<stdio.h>
struct examination
{
int acctNum;
int type;
int knowledge;
char content[100];
char answer[10];
};
main()
{
int i;
struct examination blankexam = {0,0,0,"",""};
FILE * cfPtr;
if((cfPtr = fopen("data.dat","w")) == NULL)
{
printf("File could not be opened.");
getch(); 
}
else 
{
for(i=1;i<=100;i++)
fwrite(&blankexam,sizeof(struct examination),1,cfPtr);
fclose(cfPtr);
printf("opened file");
getch();
}
return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?