| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 388 人关注过本帖
标题:这段代码运行有错,谁能帮我看看?
只看楼主 加入收藏
小菜鸟一枚
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2015-4-30
收藏
 问题点数:0 回复次数:2 
这段代码运行有错,谁能帮我看看?
#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);}
搜索更多相关主题的帖子: include choice 记单词 
2015-06-16 21:15
小菜鸟一枚
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2015-4-30
收藏
得分:0 
来个好人帮忙看看。。。
2015-06-16 21:15
小菜鸟一枚
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2015-4-30
收藏
得分:0 
#include<stdio.h>
#include<stdlib.h>

typedef void(*menuFun)();

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;
}

int main()
{
    menu();
}

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);}



醉了,为什么这样就可以运行?
2015-06-16 21:18
快速回复:这段代码运行有错,谁能帮我看看?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.033835 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved