实现功能:
使用上下键切换菜单项
使用左右键返回或进入
使用Esc键退出菜单
编译通过:VS2013
代码如下:
#include <iostream>
using std::cout;
using std::endl;
#include <string>
using std::string;
#include <conio.h>
#include <windows.h>
#define MI 3//menu iterm number
void gotoxy(int x, int y)
{
COORD coord;
coord.X = x;coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
int main(void)
{
int fr = 0;//sign to row
int fc = 0;//sign to column
int g;//gets the keyboard value
string bars = "\n\n\t\t------------------------------------------------\n"
"\t\t|***-------------- Menu Bar --------------***|\n"
"\t\t------------------------------------------------\n";
string menu[MI] =