#include <iostream>
using namespace std;
int main(){
cout << endl;
cout << "Welcome to the wonderful world of a spy" << endl;
cout << "Today we are to decode some information that has been provided." <<endl;
string response;
cout << "Are you ready?" << endl;
cin >> response;
if (response == "yes", "y", "Yes", "Y"){
cout << "Alright, let's go!!!" << endl;
}
else {
cout << "Well, too bad. We are going to do it anyways." << endl;
}
}
Exact Code這是我的代碼到目前爲止。我不能說「好吧,我們走吧!!!我做錯了什麼?問題和如果語句包含一個字符串在C++
讓我們從一個實際的代碼片段開始,而不是一個截圖。代碼進入你的問題。 – Thebluefish
請不要試圖猜測語法。這個'if'語句的結果是''Y''的評估,它總是'true'(剩下的被丟棄,它們沒有副作用)。請獲得[好書](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) – Rakete1111