C++ の while ループに問題があります。while ループは常に最初に実行されますが、プログラムが while ループの cin に到達すると、while ループは完全に機能します。前もって感謝します。また、問題がわかりにくい場合は申し訳ありません。私はまだ初心者です。
cout<<"Would you like some ketchup? y/n"<<endl<<endl<<endl; //Ketchup
selection screen
cin>>optketchup;
while (optketchup != "yes" && optketchup != "no" && optketchup != "YES" && optketchup != "Yes" && optketchup != "YEs" && optketchup != "yEs" && optketchup != "YeS"
&& optketchup != "yeS" && optketchup != "YeS" && optketchup != "yES" && optketchup != "y" && optketchup != "Y" && optketchup != "No" && optketchup != "nO"
&& optketchup != "NO" && optketchup != "n" && optketchup != "No");
{
cout<<"You have entered an entered "<<optketchup<<" which is an invalid
option. Please try again."<<endl;
cin>>optketchup;
}
if (optketchup == "yes" || optketchup == "YES" || optketchup == "Yes" || optketchup == "YEs" || optketchup == "yEs" || optketchup == "YeS"
|| optketchup == "yeS" || optketchup == "YeS" || optketchup == "yES" || optketchup == "y" || optketchup == "Y")
{
slcketchup == "with";
}
else
{
slcketchup == "without";
}
cout<<"Your sandwich shall be "<<slcketchup<<" ketchup."<<endl;
system ("pause");
もう一度、よろしくお願いします。