这段代码运行有错,谁能帮我看看?
#include<stdio.h>#include<stdlib.h>
typedef void(*menuFun)();
int main()
{
menu(void);
}
int menu(void)
{
void exit(void),
funA(void),
funB(void),
funC(void),
funD(void);
menuFun funcs[5]={exit,funA,funB,funC,funD};
int choice,i;
do
{
printf(" \n");
printf("**********************方便记单词**********************\n");
printf(" \n");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
printf(" 1.所有单词 2.单个单词 \n");
printf(" \n");
printf(" 3.词汇考试 4.查看成绩 \n");
printf(" \n");
printf(" 0.退出程序 \n");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
printf("请输入您的选择(0-4):");
for(i=0;i<3;i++)
{
scanf("%d",&choice);
if(choice>=0 && choice<=4) funcs[choice]();
}
}while(1);
return 0;
}
void funA(void)
{
FILE *fp;
char ch;
if((fp=fopen("c:\\单词.txt","r"))==NULL)
{
printf("打开文件失败。\n");
exit(1);
}
while((ch=fgetc(fp))!=EOF)
putchar(ch);
fclose(fp);
printf("\n");
exit(0);
}
void funB(void)
{ printf("单个单词\n");exit(0);}
void funC(void)
{ printf("词汇考试\n");exit(0);}
void funD(void)
{ printf("查看成绩\n");exit(0);}
void exit(void)
{ system("exit");exit(0);}