关于编写c语言菜单的问题!

我想问一下 怎么入手用c语言编写简单的菜单 望大神帮忙!谢谢了

最简单的就是printf按照行输出功能的每一项,每个功能指定一个按键。
然后让用户输入一个字符,再switch判断对应的是什么功能,再跳转到对应的子程序执行。

C 语言本来不支持菜单,如果是简单的可以按 caozhy 的方案。
如果想高级一些,需要通过 Graphics 画图的函数来实现。这个功能,Google 一下可能会有示例哦。

switch case判断用户在shell或控制台中输入的参数,在main函数中调用如下方法,将main的argcargv传进去:

ngx_get_options(int argc, char *const *argv)
{
    u_char     *p;
    ngx_int_t   i;

    for (i = 1; i < argc; i++) {

        p = (u_char *) argv[i];

        if (*p++ != '-') {
            ngx_log_stderr(0, "invalid option: \"%s\"", argv[i]);
            return NGX_ERROR;
        }

        while (*p) {

            switch (*p++) {

            case '?':
            case 'h':
                           /* 比如这里是要显示帮助  */
                ngx_show_version = 1;
                ngx_show_help = 1;
                break;

            case 'v':
                ngx_show_version = 1;
                break;
            //略...

            default:
                ngx_log_stderr(0, "invalid option: \"%c\"", *(p - 1));
                return NGX_ERROR;
            }
        }

    next:

        continue;
    }

    return NGX_OK;
}

然后是main函数根据上面的函数确定的用户输入来执行,比如如果用户键入了nginx -h(你的程序比如叫myapp,就适用myapp -h)就显示帮助信息:

    if (ngx_show_version) {
        ngx_write_stderr("nginx version: " NGINX_VER_BUILD NGX_LINEFEED);

        if (ngx_show_help) {
            ngx_write_stderr(
                "Usage: nginx [-?hvVtq] [-s signal] [-c filename] "
                             "[-p prefix] [-g directives]" NGX_LINEFEED
                             NGX_LINEFEED
                "Options:" NGX_LINEFEED
                "  -?,-h         : this help" NGX_LINEFEED
                "  -v            : show version and exit" NGX_LINEFEED
                "  -V            : show version and configure options then exit"
                                   NGX_LINEFEED
                "  -t            : test configuration and exit" NGX_LINEFEED
                "  -q            : suppress non-error messages "
                                   "during configuration testing" NGX_LINEFEED
                "  -s signal     : send signal to a master process: "
                                   "stop, quit, reopen, reload" NGX_LINEFEED
#ifdef NGX_PREFIX
                "  -p prefix     : set prefix path (default: "
                                   NGX_PREFIX ")" NGX_LINEFEED
#else
                "  -p prefix     : set prefix path (default: NONE)" NGX_LINEFEED
#endif
                "  -c filename   : set configuration file (default: "
                                   NGX_CONF_PATH ")" NGX_LINEFEED
                "  -g directives : set global directives out of configuration "
                                   "file" NGX_LINEFEED NGX_LINEFEED
                );
        }

可以用MFC来编写,很简单。

uint8_t FunChoose = 0;
void ShowMenu(void)
{
printf("\r\n***************************\r\n");
printf("Your new menu:\r\n");
printf("a: FunctionA!(Input 'a' or 'A')\r\n");
printf("b: FunctionB!(Input 'b' or 'B')\r\n");
printf("c: FunctionC!(Input 'c' or 'C')\r\n");
printf("d: FunctionD!(Input 'd' or 'D')\r\n");

printf("e: FunctionE!(Input 'e' or 'E')\r\n");
printf("Input your choice: ");
}

void GetFunChoose(void)
{
ShowMenu();
while(FunChoose == 0);
if(FunChoose == 'a' || FunChoose == 'A')
{
printf("\r\nYou choose function a\r\n");
}
else if(FunChoose == 'b' || FunChoose == 'B')
{
printf("\r\nYou choose function b\r\n");

}
else if(FunChoose == 'c' || FunChoose == 'C')
{
printf("\r\nYou choose function c\r\n");
}
else if(FunChoose == 'd' || FunChoose == 'D')
{
printf("\r\nYou choose function d\r\n");

}
else if(FunChoose == 'e' || FunChoose == 'E')
{
printf("\r\nYou choose function e\r\n");
}
else
printf("\r\nYou input error choice.\r\n");
FunChoose = 0;

}

void main()
{
while(1)
{
GetFunChoose();
}
}

建议学习MFC,网上有个将MFC的视频的,很简单的

单纯的用c++画空间应该是没有的,要借助第三方工具才可以的