不知道发生了什么.我查看了与此问题类似的其他帖子,但到目前为止还没有任何解决方案.这是包含错误的部分的注释的代码.有一次,它说!=不起作用,在其余的代码中,它说<<不起作用.
#include <iostream>
#include <algorithm>
#include <vector>
#include <ctime>
#include <cstdlib>
#include <cctype>
using namespace std;
//Hangman
int main()
{
//setup
vector<string> words;
words.push_back("GUITAR");
words.push_back("VIRGINIA");
words.push_back("LAPTOP");
words.push_back("WIFEY");
words.push_back("IPHONE");
srand(static_cast<unsigned int>(time(0))); //randomly select a word
random_shuffle(words.begin(), words.end());
const string THE_WORD = words[0];
const int MAX_WRONG = 8; //initialize wrong guesses
int wrong = 0;
string soFar(THE_WORD.size(), '-'); //initalize the word so far with dashes
string used = " "; //initalize letters used
cout << "Welcome to Hangman. Good luck!/n";
//game loop …Run Code Online (Sandbox Code Playgroud) c++ ×1