Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can someone help me, i'm having troubles with a Hangman program on C++ where there seems to be occuring some errors: - in the first
Can someone help me, i'm having troubles with a Hangman program on C++ where there seems to be occuring some errors: - in the first photo, I have this: no operator ">>" matches these operands - in the second photo I have this: identifier "turns" is undefined - in the third photo I have this: expected a declararion on: }while(fg == 'y' || fg == 'Y'); If someone can create the program and fix the errors and post ir here this will be really helpful. O play0 dangman e#include #includecfstream> #includecstring.h> #includectime.h> using namespace std; Bclass Hangman private: string word; public: //function to read a word from the file void readFile() ifstream fin; fin.open("words.txt"); if (!fin.is_open()) {( cout "File not open" > arr[i]; srand (time(0)); int i - rand(() % 10; word - arr[i]; fin.close(); //function to play Hangman void play() { //variable declaration int i, n, turn- 5, guessNo - e; char str[5], starwd[5], guesswd [5], wl, 1, fg = e; //create the star word for (i = 0; str[i] != '\'; i++) starwd[i] - *'; strcpy(str, word.c_str()); starwd[i] = '\'; //start play cout "Ready to start! The word is:" > wl; 1/check if word if (wl -- (,M. //prompt user to enter to guess the word cout "What is your guessed word?: "; //read the choice word cin >> guesswd; //check if equal with the word if (!strcmp(str, guesswd))fg = 1; //break; else if (wl -- 'l') //prompt user to enter to guess the letter cout "What letter have you chosen?: "; //read the choice cin >> 1; fg - 0; //change the star word for (i = 0; i > fg; printf(" * * "); return 0; wbile (fg 'y' || fg=='Y')
- in the first photo, I have this: no operator ">>" matches these operands
- in the second photo I have this: identifier "turns" is undefined
- in the third photo I have this: expected a declararion on: }while(fg == 'y' || fg == 'Y');
If someone can create the program and fix the errors and post ir here this will be really helpful.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started