如何在控制台应用程序中制作无限菜单 [英] How to Make an Infinite Menu in Console Application

查看:77
本文介绍了如何在控制台应用程序中制作无限菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.

我这里有一个小问题.让我解释一下.

我想要做的是从用户那里获取一个十进制数字(0到9),并根据该数字进行工作.操作后,程序应无限次询问用户该怎么做.

我知道这是一件容易的事,但做不到:/
我怎样才能做到这一点?

任何示例,定义,代码都将不胜感激:)

Hey everyone.

I have a little problem here. Let me explain.

What I want to do is to get a decimal number(0 to 9) from user and do the work according to the number. After operation, The program should ask again what to do to user in an infinite manner.

I know this is an easy thing to do, but could''nt make it :/
How can I achieve this?

Any examples, definitions, codes will be appreciated :)

推荐答案

类似这样的东西,
Something like this,
int nChoice;
while(1)
{
    printf("Choose a Number between 0 to 9(-1 to exit):"); //i just taken -1 to exit
    scanf("%d", &nChoice);
    if(nChoice == -1)
        break; //Break the loop;
    //else 
    //Do your work
}


这篇关于如何在控制台应用程序中制作无限菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆