cin
そのため、 andswitch
ステートメントを使用するときにいくつか問題があります。最初に、プログラムは次のプロンプトを表示しますint
。
cout << "How many registers would you like to use?: ";
cin >> kassor;
後で、ユーザーは選択を求められます。
cout << endl << "Press \"S\" to run the queue simulator and/or make a timestep." << endl;
cout << "Press \"Q\" to quit." << endl << endl;
cout << "Choice: ";
cin >> choice;
switch (choice)
{
case 's':
case 'S':
{
cout << "test";
nya = newCustomers();
break;
}
case 'q':
case 'Q':
{
return 0;
}
}
ここで、「q」オプションは正常に機能しますが、「s」オプションは機能しません。まだ入力を待っているかのように、「ハング」します。などなど色々試しcin.ignore()
ましたがだめでした。
私を困惑させるのは、
switch (choice)
{
case 's':
case 'S':
{
cout << "test";
nya = newCustomers();
break;
何も与えませんが、次のとおりです。
switch (choice)
{
case 's':
case 'S':
{
cout << "test";
cin.ignore(1024, '\n');
nya = newCustomers();
break;
「テスト」を出力します。
cin
ここでの私の主な質問は次のとおりですcase: s
。
前もって感謝します :