私が構築しているプログラムは、switch ケースを含む無限 while ループで実行されます。ケースごとにwhileループを挿入し、ループ内でいくつかの操作を実行したいのですが、キーボード入力が与えられるとすぐにループを終了する必要があります。そのため、キーボードから入力を取得した後、ネストされた while ループを使用して別のケースが実行され、プロセスが続行されます。
構造は次のとおりです。
while()//infinite loop
{
............... //operations
............... //operations
switch()
{
case 1:
............... //operations
............... //operations
while()//infinite loop
{
..............
..............
exit if there is any input from keyboard
}
break;
case 2:
............... //operations
............... //operations
while()//infinite loop
{
..............
..............
exit if there is any input from keyboard
}
break;
case n:
............... //operations
............... //operations
while()//infinite loop
{
..............
..............
exit if there is any input from keyboard
}
break;
}
}
何か方法はありますか???