Можно ли проверить ввод в строковом формате? [дубликат]C++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 Можно ли проверить ввод в строковом формате? [дубликат]

Сообщение Anonymous »


The code below is the module that is supposed to check if another game should be played. However, even when typing yes or no, it still detects newGame as false, thus causing the while loop to iterate indefinitely regardless of input. What is the issue?
string askNewGame() { //Declare variable to store whether to run another game. string newGame = "no"; //Ask if the program should run another game. cout > newGame; //Ensure yes or no are entered. while (newGame != "yes" || "no") { cout > newGame; } return newGame; }

Источник: https://stackoverflow.com/questions/780 ... ing-format
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»